npm.io
0.1.0 • Published 7 years ago

gulp-velocityjs2

Licence
MIT
Version
0.1.0
Deps
6
Size
5 kB
Vulns
2
Weekly
0
Stars
1

gulp-velocityjs2

Gulp compile plugin for velocity(http://velocity.apache.org/) template.

npm npm

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.

License

MIT

Keywords