4
我想写一个构建在Express上的行程应用程序。 Swig是模板引擎。我对Swig的autoescape功能感到困惑。它究竟做了什么?什么是用于Node.js的Swig模板中的自动换码?
痛饮documentation例如:
"Control auto-escaping of variable output from within your templates."
// myvar = '<foo>';
{% autoescape true %}{{ myvar }}{% endautoescape %}
// => <foo>
{% autoescape false %}{{ myvar }}{% endautoescape %}
// => <foo>
我的代码:
<script>
{% autoescape false %}
var all_hotels = {{ hotels | json }};
var all_restaurants = {{ restaurants | json }};
var all_things_to_do = {{ things_to_do | json }};
{% endautoescape %}
</script>
谢谢。
谢谢,这是有道理的。 – user2954463
我一直在寻找小时如何防止swig做到这一点。谢谢!! – Radioreve