-
Notifications
You must be signed in to change notification settings - Fork 847
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
Whitespace Slurping with expression/output tag'<%=, <%-'. #289
Comments
Nice idea. But it may break existing templates: So there may be existing templates, that contain Of course (almost) any change to the tokens could break existing code.
Also there is the question @mde if it is generally more desirable to keep it to single modifier chars. To avoid breaking changes, there are chars that can (afaik) not be at the start of any javascript expression: ^ & # * = |
This brings up the question that has never really had a definite decision: Should EJS support whitespace-sensitive stuff like markdown, yaml, etc? The fact is, EJS was designed primarily for HTML, which is not whitespace-sensitive. Sometimes I feel even the whitespace tags we do have add too much complexity. Do we add this? Then do we add the next whitespace-only request we get? Where do we stop? How many opening/closing tags are too many in the interests of keeping EJS simple? |
The alternative are
|
@User4martin What do you say ? |
That does look weird, though. @mde Is this a feature we want? |
Definitely seems more reasonable to provide hooks to this for a plugin. We already have too many different permutations of whitespace stripping or formatting directly in EJS. Rather than building more and more facilities for handling formatting, we should be making it easy for people to offload that formatting to their chosen tools. I'm going to close this issue now, although I would love some input on an API for making plugins easy to use. |
Feature: Add support for having expression/output tags which support removing white space before them.
Description: Need expressions tag which can also remove the white space before the tag.
Its a combination of
<%=
and<%_
.Tags Introduced:
<%=_
Outputs the value into the template (escaped), strips all whitespace before it<%-_
Outputs the unescaped value into the template, strips all whitespace before itUse case:
I want to write markdown inside the EJS template.
Since markdown heavily relies on indentation(and whitespaces), I want my EJS code to be indented in itself but not adding extra white space to markdown.
Example
For generating a markdown like following.
Basic implementation.
To write indented code.
Implementation with existing tag('Whitespace Slurping' ).
Implementation with new tag.
Proposal:
#PR 290
The text was updated successfully, but these errors were encountered: