2015-12-11 52 views
1

對不起在這裏問。我試着用Google搜索它,但沒有運氣。 我在chartjs的核心腳本中找到它。<% and %>在javascript中的含義是什麼?

示例(實際的代碼片段):

// String - Template string for single tooltips 
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", 

鏈接: https://github.com/nnnick/Chart.js/blob/master/Chart.js

<%一個ctrl+f,你會看到很多。

在此先感謝!

+4

這是一個模板系統 –

+0

實例:[渲染一個變量作爲HTML在EJS](http://stackoverflow.com/questions/10326950/render-a-variable-as-html-in- EJS) –

回答

0

它是一種templating系統。例如:

<script type="text/html" id="item_tmpl"> 
    <div id="<%=id%>" class="<%=(i % 2 == 1 ? " even" : "")%>"> 
    <div class="grid_1 alpha right"> 
     <img class="righted" src="<%=profile_image_url%>"/> 
    </div> 
    <div class="grid_6 omega contents"> 
     <p><b><a href="/<%=from_user%>"><%=from_user%></a>:</b> <%=text%></p> 
    </div> 
    </div> 
</script> 
相關問題