Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
velocityjs
Advanced tools
Changelog
0.8.2 2016-05-28
Readme
Velocityjs is velocity template engine for javascript.
##Features
##Install
via npm:
$ npm install velocityjs
##Broswer
Compatible all modern broswer, You can try test case on your browser to test it.
For other lower version broswer, you need have those polyfill function.
##Examples
You can find a lot of examples from the tests directory. There is no different between the use of browser and NodeJs.
##Public API
{
// 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
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:
true
, default escape variable to html encode, you can set false to close it.{control: true}
, so $control.html
will not escape.params:
#cms(1) hello #end
, you can set {cms: true}
##Syntax
Syntax you can find from velocity user guide。
###Directives
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
##Questions
You can find help from those ways:
Recommend an other velocity.
##License
(The MIT License)
FAQs
Velocity Template Language(VTL) for JavaScript
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
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).