Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
velocityjs
Advanced tools
Changelog
2.0.0 2019-09-26
Break change
First, default escape config set to false. For example
At 1.x , result is <div>
, for 2.x, output result <div>
, no escapeHtml variable.
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 429,063 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.