-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tag autoTrim
plugin
#35
Conversation
Thanks! Also, I found some issues with this implementation:
Generate the following input (removing the spaces generated by the
Your implementation removes all spaces, even the spaces after the colon
|
I had the same thought, but it would require a change to tag plugins I think. The tokenizer needs to be aware of tags that are purely evaluated (if/else, for, set, etc), vs tags that output stuff (include, layout, value interpolation). So plugins that add tags would need to register their tags. |
Hi. I saw that you update this PR to implement the autotrim option in the trim token preprocessor. The autotrim option should be a different preprocessor, that the user can use but not enabled by default (at least for now). This is an example of how I imagine it: const tmpl = vento();
tmpl.use(autotrim({
tags: ["if", "/if", "for", "/for", "import", ...etc] // Default values
));
The trim is different as with the <p>
{{ if salute }}
Hello
{{ /if }}
</p> The idea is to output this: <p>
Hello
</p> So the trim should be:
|
+
trim markerautoTrim
plugin
Fantastic work. Thank you so much! |
This adds a new plugin (unused by default) called
autoTrim
, which automatically trims away logic tags, or tags that don't render anything.By default, the tags that are trimmed by default are:
set
,if
,else
,for
,function
(andasync
),export
,import
, comments and JavaScript.The plugin also takes options:
If enabled, any of the listed tags will be trimmed away, as if it didn't exist in the markup. It respects newlines, so it only snips out the tag, while preserving your markup.
For example,
would output
instead of