This article mainly introduces how to avoid conflicts between the Smarty and CSS syntax. The example shows how to deal with conflicts between the Smarty and the CSS braces, for more information about how to avoid syntax conflicts between Smarty and CSS, see the example in this article. Share it with you for your reference. The specific analysis is as follows:
Those familiar with CSS will soon find that there is a conflict between the syntax of Smarty and CSS, because both must use braces {}. If the CSS tag is simply embedded in the HTML document header, the "unidentifiable tag" error occurs:
{$title} ...
Don't worry, because we have three solutions.
1. extract style information from another file using link flag:
{$title}
...
2. use the literal tag of Smarty to enclose the style sheet information
These tags tell Smarty not to parse any content in the tag:
{$title} {literal} {/literal} ...
3. modify the default delimiter of Smarty
You can set the attributes of center_delimiter and center_delimiter to achieve this:
<?php require("Smarty.class.php"); $smarty=newSmarty; $smarty->left_delimiter=''; $smarty->right_delimiter=''; ... ?>
Although the three solutions can solve the problem, the first one is probably the most convenient, because it is a common practice to put CSS in a separate file. In addition, this solution does not need to modify the important default configurations (delimiters) of Smarty ).
I hope this article will help you with php programming.