Home > Backend Development > PHP Tutorial > Methods to avoid syntax conflicts between Smarty and CSS_PHP Tutorial

Methods to avoid syntax conflicts between Smarty and CSS_PHP Tutorial

WBOY
Release: 2016-07-13 10:05:58
Original
855 people have browsed it

Methods to avoid syntax conflicts between Smarty and CSS

This article mainly introduces methods to avoid syntax conflicts between Smarty and CSS. An example is analyzed of the conflict between Smarty and braces {} in CSS. For processing skills, friends in need can refer to it

The example in this article describes how to avoid syntax conflicts between Smarty and CSS. Share it with everyone for your reference. The specific analysis is as follows:

Those who are familiar with CSS will quickly find that there is a syntax conflict between Smarty and CSS, because both require the use of curly brackets {}. Simply embedding CSS tags into the header of an HTML document will result in an "unrecognized tag" error:

?

1

2

3

4

5

6

7

8

9

10

{$title}

...

1 2

3

4

5

6

7

1

2

3

4

5

6

{$title}

...

8 9

10

{$title}

1

2

3

4

5

6

7

8

9

10

11

12

{$title}

{literal}

{/literal}

...

1

2

3

4

5

6

7

require("Smarty.class.php");

$smarty=newSmarty;

$smarty->left_delimiter='';

$smarty->right_delimiter='';

...

?>

...
Don’t worry because we have 3 solutions. 1. Use the link tag to extract style information from another file: ?
1 2 3 4 5 6 {$title} ...
2. Use Smarty’s literal tag to surround style sheet information These tags tell Smarty not to parse anything within this tag: ?
1 2 3 4 5 6 7 8 9 10 11 12 {$title} {literal} {/literal} ...
3. Modify Smarty’s default delimiter This can be done 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 all 3 solutions will solve the problem, the first of them is probably the most convenient since putting CSS in a separate file is a common practice. Furthermore, this solution does not require modification of Smarty's important default configuration (delimiters).

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/962923.htmlTechArticleMethods to avoid syntax conflicts between Smarty and CSS. This article mainly introduces methods to avoid syntax conflicts between Smarty and CSS, with examples. Analyzed the skills for handling conflicts between braces {} in Smarty and CSS. Friends in need...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template