Introduction to smarty literals
Smarty literals provide a way to include anything inside the tags without interpreting. Literals are useful when inserting javascript and css code inside your templates. Smarty uses delimiters to define its variables and code. The default delimiters of smarty is { and }. Since js and css contain these curly braces in the code it is not possible to insert js and css normally inside smarty templates. So we need to wrap the js and css code inside literals.
Including js in smarty tpl
Including css in smarty tpl
Customize default delimiters in smarty
You can change the default delimiter values inside the php code by changing the left_delimiter and right_delimiter variables of template object.
$tpl = new Template(); $tpl->left_delimiter = ""; $tpl->assign('variable','sample_value'); $tpl->display('test.smarty');
Sample smarty Template
Leave a Reply