How to avoid conflicts between Smarty and CSS syntax _ php instance

Source: Internet
Author: User
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.

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.