Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
node-tjs
Advanced tools
Readme
模板引擎
<%%>
单引号/双引号/反引号/正则表达式
中包含分隔符会自动识别并忽略, 例如 <%var str = 'this is a <%test%>'%>
😊
这里使用 jsperf 测试几个模板引擎的渲染分页器的性能
jade/pug
因为语法特殊所以单独写了 pugCode
模板做测试.lodash
中 _.template
方法对 -
和 =
的处理正好和 ejs 相反, 模板单独用的 lodash-code
ejs/ejs2/art-template/lodash
一样的问题在于: 没有对模板中js逻辑中的 引号/注释/正则
做特殊处理, 一旦其中包含分隔符如 <% %>
, 则会直接导致渲染错误. 例如 <%='hello%>' + name%>abc
, <%var reg = /\w+%>/%>123
, <%/*<%comment%>*/%>def
测试结果如图所示 ⬇︎
$ npm i node-tjs
或者直接引入
<script src="https://flfwzgl.github.io/tjs/lib/tjs.min.js"></script>
模板 tpl
<%list.forEach(function (item, i) {%>
<div><%=item%></div>
<%})%>
使用
var render = tjs(tpl);
render({
list: ['Tom', 'Lucy', 'Jack']
})
输出
<div>Tom</div>
<div>Lucy</div>
<div>Jack</div>
MIT
html template engine
<%%>
single quote/double quote/backquote/regular expression
can be recognized automatically, such as <%var str = 'this is a <%test%>'%>
😊npm i node-tjs
or include directly
<script src="https://flfwzgl.github.io/tjs/lib/tjs.min.js"></script>
template save as tpl
<%list.forEach(function (item, i) {%>
<div><%=item%></div>
<%})%>
invoke
var render = tjs(tpl);
render({
list: ['Tom', 'Lucy', 'Jack']
})
output
<div>Tom</div>
<div>Lucy</div>
<div>Jack</div>
MIT
FAQs
html templates engine
The npm package node-tjs receives a total of 0 weekly downloads. As such, node-tjs popularity was classified as not popular.
We found that node-tjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.