gulp-thymeleaf

0.1.3 • Public • Published

gulp-thymeleaf

Thymeleaf plugin for gulp

Install

$ npm install --save-dev gulp-thymeleaf

Example

Give only context for template

const gulp = require('gulp');
const thymeleaf = require('gulp-thymeleaf');
 
gulp.task('html', function() {
  gulp.src('./src/**/*.html')
      .pipe(thymeleaf({ userName: 'Chuck Norris' }))
      .pipe(gulp.dest('./build'))
})

Give context and options for template

const fs   = require('fs')
const gulp = require('gulp');
const thymeleaf = require('gulp-thymeleaf');
 
gulp.task('html', function() {
  gulp.src('./src/**/*.html')
      .pipe(thymeleaf({ userName: 'Chuck Norris' },
                      { templateResolver: name => fs.readFileSync(`templates/${name}.html`) }))
      .pipe(gulp.dest('./build'))
})

Give only options for template

const fs   = require('fs')
const gulp = require('gulp');
const thymeleaf = require('gulp-thymeleaf');
 
gulp.task('html', function() {
  gulp.src('./src/**/*.html')
      .pipe(thymeleaf({}, { templateResolver: name => fs.readFileSync(`templates/${name}.html`) }))
      .pipe(gulp.dest('./build'))
})

API

thymeleaf(context, options)

context

Type: Hash Default: {}

options

Type: Hash Default: thymeleaf.Thymeleaf.STANDARD_CONFIGURATION

Given options will override STANDARD_CONFIGURATION.

See available options on ThymeleafJS document.

Note

  • Default options are based on STANDARD_CONFIGURATION which makes prefix th (NOT thjs).

Package Sidebar

Install

npm i gulp-thymeleaf

Weekly Downloads

7

Version

0.1.3

License

MIT

Unpacked Size

4.19 kB

Total Files

4

Last publish

Collaborators

  • yadex205