What is the proper way to insert line break in expressions?
I was writing a zola shortcode to highlight codes from file, like this:
{% set source = load_data(path="path/to/hello.c") %}
{{ "```c\n" ~ source ~ "\n```" | markdown | safe }}
But the \n doesn't work, just appears as "\n" rather than line break. What is the proper way to implement this? Thanks!
Hm try to put the | safe before the | markdown as well?
Unfortunately that doesn't seem to work:
<pre>{{ "\n" | safe }}</pre>
<pre>{{ "\n" | safe | markdown }}</pre>
<pre>{{ "\n" | safe | markdown | safe }}</pre>
Results in
<pre>\n</pre>
<pre><p>\n</p></pre>
<pre><p>\n</p></pre>
As you can see, the \n is never converted to a newline.
I have a similar case to the OP: I want to create a shortcode that will generate the backticks so that it can include syntax highlighting.
Note that I've found a workaround: replace \n with a literal newline, eg:
<pre>{{ "hello" ~ "
" ~ "world" }}</pre>
Not the nicest, but hey it works.
Related: https://github.com/Keats/tera/issues/663
Probably too much escaping going on.
Just hit the same issue trying to run - {{ outputs | join(sep="\n -") }}
Yeah it's not working in the current version. v2 has it working already