eta-dev/eta

Add an Output function (like EJS's `outputFunctionName`)

Opened this issue · 1 comments

Is your feature request related to a problem? Please describe.

Often I'd like the ability to output code from a function rather than having to close / open the tags to do this. In EJS this is possible via the outputFunctionName option.

In short, I'd like to be able to write something like:

<% if (condition) { print(`string ${variable} string`) } %>

rather than:

<% if (condition) { %>string <%= variable %> string<% } %>
// or, more likely:
<% if (condition) { -%> string <%= variable %> string <%- } %>

Describe the solution you'd like

Either a function, or the documentation to make a function, that will allow me to output directly without opening and closing tags excessively. My IDE (WebStorm) doesn't support ETA with customised tags at all (I like <? / ?>), and provides terrible EJS support too, so I'm basically looking at monocoloured code files and find the first form far more familiar to me (and easier to type).

Describe alternatives you've considered

Opening and closing tags a lot! This is very annoying when refactoring EJS code that could take advantage of the outputFunctionName

@paul-norman I like this idea. If anyone wants to contribute a PR, let's call the output function output by default.