Skip to content
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

Question: how to escape "<%" and "%>“ #5

Closed
nneesshh opened this issue Jun 28, 2018 · 2 comments
Closed

Question: how to escape "<%" and "%>“ #5

nneesshh opened this issue Jun 28, 2018 · 2 comments

Comments

@nneesshh
Copy link

nneesshh commented Jun 28, 2018

Hi, @leafo
When I use chart.js , it uses a legend template filed like this:

//String - A legend template
legendTemplate: '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].lineColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',

etlua should not translate "<%" and "%>" in this string, how can I escape them?

@leafo
Copy link
Owner

leafo commented Jun 30, 2018

There's no syntax to escape those symbols when in a template's context right now.

A workaround is you can place the symbols inside of a lua string in a lua code block: <%= "<%" %> The parser is aware of when it is in a Lua string literal in the code blocks, so it won't see the opening and closing template tags as starts of new template values.

@nneesshh
Copy link
Author

nneesshh commented Jul 4, 2018

thank you, @leafo, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants