Copyright (c) 2019-2024 Sempare Limited
Removing whitespace is a tricky problem in templates. In the template engine, attempts have been made to address this in a number of ways.
There are statements such as ignorenl and ignorews which allow for new lines and whitespaces to be stripped respectively.
Further, on the context, there are various options: eoStripRecurringNewlines, eoTrimLines, eoStripRecurringSpaces and eoConvertTabsToSpaces.
Below are some other ways in which hints can be provided to help trip whitespace and newlines.
Scripts start with <% and close with %>. These tags may have additional hints to assist with the removal of whitespace.
hello <%- 'world' %> <NL>
<NL>
This yields:
helloworld
<NL>
whitespace is removed before the '<%-', whitespace and a single newline is removed after the '%>'
This works with block statements as well
e.g.
<%- if cond %> <NL>
<% 'hello' %><NL>
<% end %><NL>
This results in:
hello<NL>