Ways to avoid smarty conflicts with CSS Syntax _php tutorial

Source: Internet
Author: User

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:

?

1

2

3

4

5

6

7

8

9

10

{$title}

...

Don't worry, because we have 3 solutions.

First, use the link tag to extract style information from another file:

?

1

2

3

4

5

6

{$title}

...

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 {} .

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.