Hi! I really like the idea of zts, and it feels like the right balance for what I want from a zig-oriented template renderer.
Right now I am using it to generate some html. Part of the sections I want to generate are inside of a white-space: pre styled element, so white space is not ignored. Ideally I would want to have sections that can be expressed inline, or at least be able to define sections that don't have line breaks.
I was considering a fork to support this, but if there is a syntax you would consider upstreaming, I would like to build that.
To make this more concrete, this is my template:
<span class="line-content">
.highlight_start
<span class="{[highlight_class]s}">
.highlight_end
</span>
.empty_line_content
.line_end
</span>
...
<style>
.line-content {
white-space: pre;
}
</style>
And the generated html:
<span class="yellow">
def</span>
<span class="purple">
fib</span>
(<span class="blue">
n</span>
: <span class="purple">
int</span>
) <span class="none">
-></span>
<span class="purple">
int</span>
:</span>
Whereas I would like it to be like this:
<span class="yellow">def</span> <span class="purple">fib</span>(<span class="blue">n</span>: <span class="purple">int</span>
) <span class="none">-></span> <span class="purple">int</span>:</span>
Some ideas:
There could be a | separator that begins a list of options, and inline would be an option to skip the line break added by the section header.
So my template would then look like this:
<span class="line-content">
.highlight_start|inline
<span class="{[highlight_class]s}">
.highlight_end|inline
</span>
.empty_line_content|inline
.line_end|inline
</span>
What I don't love about this is that the template doesn't "look" very much like the rendered html, since we have these line breaks that will go away after rendering. I do like that it is extensible to other options.
Another idea:
<span class="line-content">{.highlight_start}<span class="{[highlight_class]s}">{.highlight_end}</span>{.empty_line_content} {.line_end}</span>
What I don't like about this one is that it loses the elegance of clearly delimited sections.
In practice, I'll probably just escape the whitespace using html escape sequences, and that should solve it. - this did not work since there's no good way to fully remove whitespace within tag content, which I would need.
Hi! I really like the idea of zts, and it feels like the right balance for what I want from a zig-oriented template renderer.
Right now I am using it to generate some html. Part of the sections I want to generate are inside of a
white-space: prestyled element, so white space is not ignored. Ideally I would want to have sections that can be expressed inline, or at least be able to define sections that don't have line breaks.I was considering a fork to support this, but if there is a syntax you would consider upstreaming, I would like to build that.
To make this more concrete, this is my template:
And the generated html:
Whereas I would like it to be like this:
Some ideas:
There could be a
|separator that begins a list of options, and inline would be an option to skip the line break added by the section header.So my template would then look like this:
What I don't love about this is that the template doesn't "look" very much like the rendered html, since we have these line breaks that will go away after rendering. I do like that it is extensible to other options.
Another idea:
What I don't like about this one is that it loses the elegance of clearly delimited sections.
In practice, I'll probably just escape the whitespace using html escape sequences, and that should solve it.- this did not work since there's no good way to fully remove whitespace within tag content, which I would need.