gulp-velocityjs2
v0.1.0
Published
Gulp compile plugin for velocity(http://velocity.apache.org/) template
Downloads
35
Maintainers
Readme
gulp-velocityjs2
Gulp compile plugin for velocity(http://velocity.apache.org/) template.
Install
yarn add gulp-velocityjs2
Usage
Basic
const gulp = require('gulp');
const gulpVTL = require('gulp-velocityjs2');
gulp.task('build', ()=>{
return gulp.src('./index.vm')
.pipe( gulpVTL() )
.pipe(gulp.dest('./build'));
});
Variable
<div>hello $name</div>
gulp.task('build', ()=>{
return gulp.src('./hello.vm')
.pipe( gulpVTL({ name: 'byungi' }) )
.pipe(gulp.dest('./build'));
});
output:
<div>hello byungi</div>
API
gulpVTL([data[, options]])
Returns gulp transformer for velocity compilation.
data
Set the data values.
object
gulp.src('index.vm')
.pipe(gulpVTL({var1: 'value1', var2: 'value2'}))
file
gulp.src('index.vm')
.pipe(gulpVTL('./data.json'))
directory
If it is a directory
, set the data that matches the file name in the directory.
gulp.src('view/*.vm')
.pipe( gulpVTL('data/') )
view/main.vm
hello $value
data/main.js
export.value = 'world'
output:
hello world
options
Compile options
details https://github.com/shepherdwind/velocity.js
escape
unescape
env
blocks
ignorespace
macros
Other options
ext
Output extension name. Default is html
refresh
If this value is true, import new data from the path without cache. This is useful when in watch mode. Default is false.
Related
- shepherdwind/velocity.js
- http://velocity.apache.org
License
MIT