我正在尝试在 swig 中创建一个多行字符串变量:
{% set myVariable = "
multi
line
string
" %}
然后我记录它:
{% logMyVariable(myVariable) %}
但我不明白为什么我的变量没有显示在几行:
multi line string
而我期待:
multi
line
string
你知道我怎么能做到吗?
我正在尝试在 swig 中创建一个多行字符串变量:
{% set myVariable = "
multi
line
string
" %}
然后我记录它:
{% logMyVariable(myVariable) %}
但我不明白为什么我的变量没有显示在几行:
multi line string
而我期待:
multi
line
string
你知道我怎么能做到吗?
In HTML, new lines in text aren’t rendered when the text is displayed. For example, this HTML:
<p>Let’s split this sentence up
onto
multiple
lines.</p>
Will render like this:
Let’s split this sentence up onto multiple lines.
You might want to wrap your log
in a <pre>
tag, as that will preserve new lines (and multiple spaces between words, which are also ignored in rendered HTML):
<pre>{% logMyVariable(myVariable) %}</pre>