Heim >Backend-Entwicklung >Python-Tutorial >请问如何处理tornado模板和angular.js的 {{ }} 表达式冲突问题?
<code class="language-html"><span class="cp">
<span class="nt"> <span class="na">ng-app=</span><span class="s">"customInterpolationApp"</span><span class="nt">></span>
<span class="nt"></span>
<span class="nt"><script><span class="na">src=</script></span><span class="s">"http://code.angularjs.org/1.2.0rc1/angular.min.js"</span><span class="nt">></span>
<span class="nt"><script><span class="na">src=</script></span><span class="s">"script.js"</span><span class="nt">></span>
<span class="nt"></span>
<span class="nt"></span>
<span class="nt"><div> <span class="na">ng-app=</span><span class="s">"App"</span> <span class="na">ng-controller=</span><span class="s">"DemoController as demo"</span><span class="nt">></span>
//demo.label//
<span class="nt"></span>
</div></span>
<span class="nt"></span>
<span class="nt"></span>
</span></span></code>
angularjs的模板全部保存为独立的html文件,由nginx直接去获取?<code class="language-html"><span class="nt"><p></p></span>{{name}}<span class="nt"></span>
</code>
我们的解决方法是修改tornado的模板引擎,加入了一个plain关键字。通过像<code class="language-text">{% plain 'some_angular_template.html' %}
</code>
{{! name }}
前后端分离,不使用任何后端模板,不管是tornado的模板还是jinja2/mako, 统统干掉。前后端通过api返回json数据进行通信。
angular是为富客户端而生的产物,个人倾向于把tornado变成一个restful服务器。所以前端工程应该是放在apache下更佳,不应该与tornado放到一起。