How to convert multi-line text to HTML tags in AnQi CMS template?
linebreaks
The filter can convert multi-line text into HTML tags by line breaks. The beginning and end of each line are wrapped, and there is a blank line in the middle.<p>
And</p>
wrapped, and the middle is processed with a blank line.<br/>
.
It can also be used.linebreaksbr
different is,linebreaks
different is,linebreaksbr
Just directly replace the newline characters.<br/>
And do not add p tags at the beginning and end.
It can also be used.linenumbers
To number each line of the multi-line text, the symbol starts from 1. For example1.
.
Usage Instructions
linebreaks
How to use the filter:
{{ obj|linebreaks }}
linebreaksbr
How to use the filter:
{{ obj|linebreaksbr }}
linenumbers
How to use the filter:
{{ obj|linenumbers }}
like processing stringsthis is a text\nwith a new line in it
then it can be written like this:
{{ "this is a text\nwith a new line in it"|linebreaks }}
# 显示结果
<p>this is a text<br />with a new line in it</p>
Here is an example demonstration
linebreaks
Filter
{{ ""|linebreaks|safe }}
{{ simple.newline_text|linebreaks|safe }}
{{ simple.long_text|linebreaks|safe }}
{{ "john doe"|linebreaks|safe }}
# 显示结果
<p>this is a text<br />with a new line in it</p>
<p>This is a simple text.</p><p>This too, as a paragraph.<br />Right?</p><p>Yep!</p>
<p>john doe</p>
linebreaksbr
Filter
{{ ""|linebreaksbr|safe }}
{{ simple.newline_text|linebreaksbr|safe }}
{{ simple.long_text|linebreaksbr|safe }}
{{ "john doe"|linebreaksbr|safe }}
# 显示结果
this is a text<br />with a new line in it
This is a simple text.</p><p>This too, as a paragraph.<br />Right?</p><p>Yep!
john doe
linenumbers
Filter
{{ simple.long_text|linebreaksbr }}
# 显示结果
1. This is a simple text.
2. This too, as a paragraph.
3.
4. Right?
5. Yep!