gulp-freemarker

A plugin for Gulp to process Freemarker template files like Java.

Usage no npm install needed!

<script type="module">
  import gulpFreemarker from 'https://cdn.skypack.dev/gulp-freemarker';
</script>

README

gulp-freemarker

NPM version Build Status Coverage Status Dependency Status

freemarker plugin for gulp

Usage

First, install gulp-freemarker as a development dependency:

npm install --save-dev gulp-freemarker

Then, add it to your gulpfile.js:

var freemarker = require("gulp-freemarker");

gulp.src("./mock/*.json")
    .pipe(freemarker({
        viewRoot: "WEB-INF/views/",
        options: {}
    }))
    .pipe(gulp.dest("./www"));

You should provide mock files, which type is json:

{
    "file": "hello.ftl",
    "data": {
        "name": "World"
    }
}
  • file is relative to viewRoot, gulp-freemarker will read and process ${viewRoot}/${file} file.

  • data is the data model the template required.

API

freemarker(options)

options.viewRoot

Type: String Required: true

The directory where all templates files in.

options.options

Type: Object Default: {}

Options for Freemarker.js. see also https://github.com/ijse/freemarker.js#configurations.

License

MIT License