Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
amplify-velocity-template
Advanced tools
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 30,221 weekly downloads. As such, amplify-velocity-template popularity was classified as popular.
We found that amplify-velocity-template demonstrated a not healthy version release cadence and project activity because the last version was released 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.
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.