ejs icon indicating copy to clipboard operation
ejs copied to clipboard

How to handle tag <%- jsVariable %> where jsVariable is a string variable with several <%= %>

Open o1lab opened this issue 9 years ago • 1 comments

How to handle tag <%- jsVariable %> where jsVariable is a string variable with several <%= %>

Usecase here:

<% for(var i = 0 ; i < largeObject.elementArray.length; ++i) {%>
    <%-largeObject.elementArray[i].myTemplate%>
<%}%>

'.myTemplate' is a string variable - examples below:

largeObject.elementArray[i].myTemplate = '<%=largeObject.elementArray[i].variable_1 + largeObject.elementArray[i].variable_7 + largeObject.elementArray[i].variable_12%>'

or

largeObject.elementArray[i].myTemplate = '<%=largeObject.elementArray[i].variable_1 + largeObject.elementArray[i].variable_5 + largeObject.elementArray[i].variable_14%>'

'myTemplate' variable derivation is fairly complex and hence it is pre-calculated string - but then how do I expand 'myTemplate' string now.

My EJS knowledge is basic - I might be missing some technical correct terms explaining this problem.

o1lab avatar Dec 07 '16 12:12 o1lab

This version of EJS is no longer maintained. The current one, available on NPM, is here: https://github.com/mde/ejs

Please ask this question over there, so other folks can follow the discussion. Thanks.

mde avatar Dec 08 '16 17:12 mde