What to do with PHP Smarty delimiter conflicts

Source: Internet
Author: User
Tags smarty template
This article mainly introduces the PHP Smarty delimiter conflict How to deal with, interested in the friend's reference, I hope to help you.

The default delimiter "{" conflicts with the "{" in CSS and JS, what should I do with it?
1. All the places starting with {are empty. (Smarty only parses the contents of the delimiter and cannot have spaces after the left delimiter)
2. The CSS and JS are introduced in an external way. (Smarty does not parse external files)
3. Use the built-in function literal.
4. Change the delimiter.

The best way to resolve conflicts: external introduction of CSS and JS, for internal use of literal.

index.php (back end):

<?php  //1. Introduction of Smarty class  include ' libs/smarty.class.php ';  2. Instantiate the Smarty object  $smarty = new Smarty ();   3. Set related properties  $smarty->template_dir = "templates/";//Template directory  $smarty->compile_dir = "Templates_c";//Compile Directory  //Modify delimiter  $smarty->left_delimiter = ' <{';    Custom delimiter, default is "{"  $smarty->right_delimiter = '}> ';  4. Assigning Data  $smarty->assign (' title ', ' Smarty template engine ');  $smarty->assign (' content ', ' smarty template engine is a powerful template engine! ');  5. Load View  $smarty->display (' index.html ');

Index.html (front-end view):

<! DOCTYPE html> 

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.