[feature] include should preserve indention
See original GitHub issueIf someone does
<p>
<%- include('other.ejs') %>
</p>
and other.ejs is
<div>
<b>HELLO</b>
</div>
Then it should look like
<p>
<div>
<b>HELLO</b>
</div>
</p>
Instead of
<p>
<div>
<b>HELLO</b>
</div>
</p>
Issue Analytics
- State:
- Created 7 years ago
- Reactions:13
- Comments:17
Top Results From Across the Web
How to preserve whitespace indentation of text enclosed in ...
PRE is intended to preserve whitespace exactly as it appears (unless altered by white-space in CSS, which doesn't have enough flexibility to support ......
Read more >Preserve Indentation when inserting variable lists in a template
Say I have an octopus variable that has a list of items in it. For example, the variable is called ContainerEnvironmentVariables and it...
Read more >Adjust indents and spacing - Microsoft Support
Use Paragraph settings to change indentation, line spacing, and alignment.
Read more >Google Docs: Using Indents and Tabs - GCF Global
A great way to draw attention to important areas within your document is to add an indent or tab. There are several ways...
Read more >Indentation | IntelliJ IDEA Documentation - JetBrains
Click the widget and select Configure Indents for 'Language'. · In the dialog that opens, you can change settings for tabs and indents...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
BTW, you could also write your own function, like this:
Then you could do something like
<%- indent(include('filename'), 4) %>
if you wanted the include to be indented 4 spaces.@SBoudrias said:
Hmm. https://github.com/mde/ejs/issues/55#issuecomment-72275752.
Just wanted to apologize for my tone in my last comment. I just realized that EJS right now was very different from the EJS I worked on a year ago.
A year ago, I was optimizing EJS as if it was a finished product, i.e. literally to the last inch, including replace costly
.replace()
calls with less costly ones and with even less ones. At the end, the template performance was on par with the fastest template engines out there, but the compilation performance still not so.I approached this issue as if EJS still cared about compilation performance, but seems like we don’t any more. More specifically, features like
<%_ _%>
came along that basically added to the already slow compilation process with a bunch of unconditional.replace
calls.So again, I apologize. EJS has become something I didn’t think it was, and that anachronism in my head led to my comment.
On a more technical side, yes, those features might be doable, but will be hard to implement nevertheless. If dynamic inclusion is used, then a run-time solution like the one posed by @RyanZim would be much easier to use.