2012-07-26 50 views
3

我使用Flask,忍者和Mustachjs一起。胡子,babel和gettext

为了完成工作,我使用{%raw%}标记。

现在,它是一个多语言应用程序,我使用Babel。

我该怎么办:

{% raw %} 
    <script id="details" type="text/template"> 

     <table class="table" > 

     <thead> 
     <tr> 
       <th>**{{gettext('col1')}}</th> 
       <th>**{{gettext('col2')}}</th> 
       <th>**{{gettext('col6')}}</th> 

     </tr> 
     </thead> 
     <tbody> 
     {{#skyrsla}} 
       <tr> 
         <td> {{index}}</td> 
         <td> {{nafn}}</td> 
         <td> {{mean_growth_index}}</td> 
       </tr> 
     {{/skyrsla}} 
     </tbody> 

     </table> 
</script> 
{% endraw %} 

既然是原始标记之间,巴贝尔扩展没有检测{{gettext的(“COL1”)} 有没有办法来改变通天的配置。

我的实际配置是这样的:

[python: **.py] 
[jinja2: **/templates/**.html] 
extensions=jinja2.ext.autoescape,jinja2.ext.with_ 

回答

3

简单地结束通话之间您的原始块gettext

{% raw %} 
    <script id="details" type="text/template"> 

     <table class="table" > 

     <thead> 
     <tr> 
       <th>**{% endraw %}{{gettext('col1')}}{% raw %}</th> 
       <th>**{% endraw %}{{gettext('col2')}}{% raw %}</th> 
       <th>**{% endraw %}{{gettext('col6')}}{% raw %}</th> 

     </tr> 
     </thead> 
     <tbody> 
     {{#skyrsla}} 
       <tr> 
         <td> {{index}}</td> 
         <td> {{nafn}}</td> 
         <td> {{mean_growth_index}}</td> 
       </tr> 
     {{/skyrsla}} 
     </tbody> 

     </table> 
</script> 
{% endraw %}