【问题标题】:tornadoweb template variable pipe safetornadoweb 模板变量管道安全
【发布时间】:2012-12-10 19:24:54
【问题描述】:

在我的后端处理程序中,我发送带有双引号的字符串,例如:

print '\"test\"'
self.render('test.html', test = '\"test\"')

在模板 test.html 中,我将测试变量传递给 javascript,例如:

<script>
var test = {{ test }};
</script>

但实际上浏览器生成的是:

<script>
var test = &quo t;test&quo t;;
</script>

出现字符串引号而不是双引号“

tornadoweb 中是否有类似于 Django 管道的东西,应该可以解决问题:

<script>
var test = {{ test|safe }};
</script>

或者也许还有另一种方法可以用双引号传递字符串(我在前端确实需要)?

你好!

【问题讨论】:

    标签: javascript templates pipe tornado


    【解决方案1】:

    好的,我自己找到的:

    {% autoescape None %}
    

    【讨论】:

      猜你喜欢
      • 2020-08-20
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      • 2011-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多