Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
velocityjs
Advanced tools
Velocity Template Language(VTL) for JavaScript
Weekly downloads
Readme
Velocityjs is velocity template engine for javascript.
via npm:
$ npm install velocityjs
Compatible with all modern browsers. You can try test case in your browser to test it.
For other lower version browsers, you need have those polyfill function.
You can find a lot of examples from the tests directory. There is no different between the use of browser and NodeJs.
{
// render method
render(vm: string, context?: Object, macros?: Object): string;
parse(vm: string, config?: Object, ignorespace?: boolean): Array<Ast>;
Compile: {
(asts: Array<Ast>, config?: Object): {
render(context?: Object, macros?: Object);
};
};
}
params:
#include('path/xxx')
, you can define you inlcude
macro functionvar Velocity = require('velocityjs');
Velocity.render('string of velocity', context, macros);
context
is an object or undefined, for vm $foo.bar
, data look up path will be context.foo.bar
.
context
can have method, and call it just on velocity string.
The method of context, will have eval
method on this
of inner method body. You can eval
to rerender velocity string, such as test code $control.setTemplate.
parse
method can parse vm, and return ast tree of velocity.
Compile
will render asts to result string.
var Compile = Velocity.Compile;
var asts = Velocity.parse('string of velocity');
(new Compile(asts)).render(context, macros);
params:
false
, default not escape variable to html encode, you can set true to open it.{control: true}
, so $control.html
will not escape.development
will throw error when null values are used#set
value, @see https://github.com/shepherdwind/velocity.js/pull/105params:
#cms(1) hello #end
, you can set {cms: true}
Syntax you can find from velocity user guide。
Directives supports have set
, foreach
, if|else|elseif
, macro
, break
, stop
.
Some othe directive evaluate
, define
, parse
, do not supported default, but You can realize by context or macros, for example parse
You can find help from those ways:
Recommend an other velocity.
(The MIT License)
FAQs
Velocity Template Language(VTL) for JavaScript
The npm package velocityjs receives a total of 375,942 weekly downloads. As such, velocityjs popularity was classified as popular.
We found that velocityjs 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
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.