Ways to avoid smarty conflicts with CSS syntax
This article mainly introduces the method of avoiding the conflict between Smarty and CSS syntax, and analyzes the techniques of dealing with the conflict between Smarty and CSS in parentheses {}.
The examples in this article describe ways to avoid conflicts between Smarty and CSS syntax. Share to everyone for your reference. The specific analysis is as follows:
People familiar with CSS will soon find that Smarty and CSS have conflicting syntax because both require braces {}. If you simply embed a CSS tag in the HTML document header, it will cause an "unrecognized tag" error:
?
Don't worry, because we have 3 solutions.
First, use the link tag to extract style information from another file:
?
Second, use the literal tag of smarty to enclose the style sheet information.
These tokens tell Smarty not to parse anything inside the tag:
?
1 2 3 4 5 6 7 8 9 10 11 12 |
{$title} {literal} {/literal} ... |
Third, modify the default delimiter for Smarty
You can do this by setting the Center_delimiter and Center_delimiter properties:
?
1 2 3 4 5 6 7 |
Require ("Smarty.class.php"); $smarty =newsmarty; $smarty->left_delimiter= '; $smarty->right_delimiter= '; ... ?> |
While 3 solutions solve the problem, the first of these may be the most convenient, because putting CSS in a separate file is a common practice. In addition, this solution does not need to modify the important default configuration (delimiter) of Smarty.
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/962923.html www.bkjia.com true http://www.bkjia.com/PHPjc/962923.html techarticle ways to avoid conflicts between Smarty and CSS syntax this article mainly introduces the method to avoid the conflict between Smarty and CSS syntax, and analyzes the techniques of dealing with the conflict between Smarty and CSS in braces {} .