Okay I've been searching for this one and found a possible duplicate here (what does " <%: " do?). However this question adresses <%= and <%:, but not <%-.
So just to be sure I'm still asking my question.
I'm trying to setup a node.js/express/d3 application rendered on the server side. I found a repo describing what I want to do here: https://github.com/gregjopa/d3-server-side-demo/blob/master/index.html
In that html code there is a snippet that I'd like to actually convert in jade:
<h1>D3 Server-side Demo</h1>
<%-
barChartHelper.getBarChart({
data: fixtureData,
width: 400,
height: 300,
xAxisLabel: '2012',
yAxisLabel: 'Views',
containerId: 'bar-chart-small'
})
%>
So I have two questions: 1)What is the meaning of the <%- %> in html? And 2) How do I write this in jade? Thanks,
The codebase you linked has EmbeddedJS as a dependency. EJS is a templating library which allows for using those tags.
Unescaped buffering with
<%- code %>
So basically: These are not HTML tags, just tags belonging to a different templating language that allow inline JS code to be executed
You can use the same in Jade as explained in the docs
Unescaped Buffered Code
Unescaped buffered code starts with
!=
and outputs the result of evaluating the JavaScript expression in the template.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With