ViewFish PHP Templating Engine
Extention
ViewFish can process other functions in templates using the extend() method. For example: $t->extend(['function1','function2','function3']); will add additional functionality to the templating process.
A few notes: functions will only work if they 1) accept a string with no further arguments and 2) return a string. The built-in PHP functions that ViewFish Templating is known to support are: addcslashes, addslashes, bin2hex, chop, chr, chunk_split, convert_cyr_string, convert_uudecode, convert_uuencode, count_chars, crc32, crypt, get_html_translation_table, hex2bin, html_entity_decode, htmlentities, htmlspecialchars_decode, lcfirst, ltrim, metaphone, money_format, ord, quotemeta, rtrim, sha1, soundex, str_rot13, str_word_count, stripcslashes, strlen, strrev, strtok, floatval, ceil, floor
ViewFish will not accept the following functions, as they can create dangerous execution conditions:
exec, system, passthru, shell_exec, popen, proc_open, pcntl_exec, eval, assert, create_function, call_user_func, call_user_func_array, file_get_contents, file_put_contents, fopen, fwrite, unlink, rmdir, mkdir, rename, copy, move_uploaded_file, curl_exec, curl_multi_exec, parse_str, extract, putenv, ini_set, dl, mail, header, preg_replace
You can also define your own function extensions. For example:
function custom_function($string) {
return '"<i>'.ucwords(strtolower($string))."-".strtoupper($string).'"</i>';
}
$T->extend(['custom_function']);
is valid syntax and will enable custom_function() inside your ViewFish templates.
You can see examples of Viewfish at viewfish.sethadam1.com/examples/