4

Express 上に構築された旅程アプリを作成しようとしています。Swig はテンプレート エンジンです。Swig の自動エスケープ機能に戸惑っています。それは正確に何をしますか?

Swigドキュメントの例:

"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>

ありがとうございました。

4

1 に答える 1