How do I deal with the tornado template and the angular.js {{}} expression conflict problem?

Source: Internet
Author: User

Reply content:

Angular supports custom delimiters with $interpolateprovider starting from 1.0 / http docs.angularjs.org/api/ Ng.%24interpolateprovider

Because angular native supports custom delimiters, and some backend template languages do not support custom delimiters, individuals tend to customize the delimiter on the angular side. While there are various hack that allow the front and back ends to be delimited with {{}}, this makes the front-and-back code more difficult to discern and less maintainable, so it is not recommended to have the same delimiter in the backend template and mix.

   <>< span=""> 
    ng-app=
    "customInterpolationApp"
    >  
        
        
      
      
        
     ng-app="App" ng-controller="DemoController as demo">        //demo.label//      
   <>
Angularjs template is all saved as a separate HTML file, directly from Nginx to get it?

If you need to dynamically generate ANGULARJS templates through tornado, can you consider refactoring the code to avoid this? Another workaround is to replace two curly braces with ng-bind, such as:

{{name}}

Our solution is to modify the Tornado template engine, adding a plain keyword. Through the like
{% plain 'some_angular_template.html' %}
{{! name}} is detached from the front and back end, without any backend templates, whether it's a tornado template or a Jinja2/mako, kill it all. The front and back end communicates with the JSON data through the API. Angular is a product of rich clients, and individuals tend to turn tornado into a restful server. So the front-end project should be placed under Apache better, should not be put together with tornado.

With the popularity of the TSA, application servers are moving toward lightweighting. If only as a Web project, individuals do not recommend heavy use of angular. Should consider the optimization of SEO, go freemaker route. Go directly to the Tornado template render part of the source code to change a few lines of code to another you want the tag like "{@ @}"
  • Related Article

    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.