Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
amplify-velocity-template
Advanced tools
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 functions:
You can find a lot of examples in the tests
directory. There are no differences between using a browser and a node.js environment.
{
// 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 include
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 context
will have eval
method on this
of inner method body. You can eval
to rerender velocity string as shown in this example: $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:
true
, default escape variable to html encode, you can set false to close 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
, return
.
Some other directives such as evaluate
, define
, parse
are not supported by default, but they can be used via 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 amplify-velocity-template receives a total of 58,589 weekly downloads. As such, amplify-velocity-template popularity was classified as popular.
We found that amplify-velocity-template demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
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.