GithubHelp home page GithubHelp logo

gulp-freemarker's Introduction

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

gulp-freemarker's People

Contributors

ijse avatar ivoputzer avatar perlow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gulp-freemarker's Issues

json文件如何模拟Java 的Date类型

我在html模版里,使用

<td>${startDate?datetime} ~ ${endDate?datetime}</td>

就是说,java渲染模版时传递的参数是Java里的Date类型。
在用gulp-freemarker渲染时,我在如何在json文件中配置呢?

When freemarker cannot parse and encounters an error, the output text is not available

fmpp returns useful output text in case of errors that is not being passed on by this plugin. could we maybe change this to add the output to the error object? In the error object currently we just have the information that the command failed.

error: Error: Command failed: /bin/sh -c blah blah
html: null
output:>>> ABORTED! <<<

The cause of aborting was:
FreeMarker template error: The following has evaluated to null or missing:
==> joe [in template "symposium-css.ftl" at line 2, column 3]

No such file or directory

I'm using a Windows machine at the moment and I'm getting the following error

Error: ENOENT: no such file or directory, open 'C:\Users\wez\AppData\Local\T
emp\30419676-678e-47a9-b92f-9cd1821fc3df'
at Error (native)

I'm using code that is almost identical to the code you have supplied in your readme.

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

My directory structure is as follows:
my-project/
gulpfile.js
package.json
mock/
-/hello.json
WEB-INF/
-/views/
--/hello.ftl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.