Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
laytpl 是一款轻量的 JavaScript 模板视图引擎,能同时运行在浏览器端及 Node.js 端,且对 Express 框架无缝兼容,模版语法遵循原生 JavaScript。
$ npm install laytpl
{{= d.field }}
{{- d.field }}
兼容性重要提示:
1.x
版本的{{ d.field }}
等同于原文输出,因此若升级到2.x
,需按照新版分隔符进行语句适配。
{{# JavaScript statement }}
{{! content !}}
如:{{!
{{= d.key }} 则不会解析这中间的内容,原字符输出
!}}
此处只演示 Express 下的使用方式
在项目入口指定 view engine
,并且定义模版文件扩展名为 .html
var express = require('express');
var app = express();
var laytpl = require('laytpl');
app.engine('.html', laytpl.__express);
app.set('view engine', 'html');
在视图文件中书写模板,支持 include 导入子模板,文件扩展名可省略。
{{# if (d.user) { }}
<h2>{{= d.user.name }}</h2>
{{# } >>
<p>{{= d.intro }}</p>
{{- include footer }}
渲染
app.get('/', function(req, res){
res.render('index', {
user: {name: 'sents'},
intro: 'a developer from China'
});
});
Custom delimiters can also be applied globally:
laytpl.config({
open: '{{',
close: '}}'
});
laytpl 默认不开启缓存,这在你开发时非常有利。但是当你的模版足够稳定,你如果需要开启该项,只需要按以下设置即可:
laytpl.config({
cache: true
});
开启缓存后的渲染速度将会得到极大的提升。
laytpl.config({
min: true
});
The MIT License
FAQs
Node.js view engine
The npm package laytpl receives a total of 8 weekly downloads. As such, laytpl popularity was classified as not popular.
We found that laytpl 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.