Skip to content

ImHype/fast-ftl

Repository files navigation

fast-ftl

The Freemaker parsing service in Node.js

NPM version build download node Code of Conduct license

中文 README

Process

How to use

npm i fast-ftl -S

Step 1 - Import

1. Import in es2015+
import Render from "fast-ftl";
2. Require in CommonJS
const {Render} = require("fast-ftl");

or

var Render = require("fast-ftl").Render;

Step 2 - Init Fast-FTL

var render = Render({
    root: path.join(__dirname, 'pages'), 
    paths: [
        path.join(__dirname, 'common')
    ], // Support MultiTemplateLoader
    defaultEncoding: "utf-8", 	 // 默认 encoding
    urlEscapingCharsetSet: "utf-8", // URLEscapingCharset
    numberFormat: "0.##########", // 数字格式化方式
    templateUpdateDelay: 0 // milliseconds 为单位
});
property Fast-FTL defaultValue
default_encoding defaultEncoding utf-8
url_escaping_charset urlEscapingCharsetSet utf-8
number_format numberFormat 0.##########
template_update_delay(Milliseconds) templateUpdateDelay 0

Step 3 - Parse file

render.parse("test.ftl", {
    YourName: "Jack"
}).then(data => {
    console.log(data);
}).catch(e => {
    console.log(e)
});

Features

  1. Fast: use Socket to invoke Java Freemarker Parser, not in Teminal.
  2. Support MultiTemplate Directory.
  3. Simple API, base on Promise.

Contributors


君羽

💻 🔌 🚇 📖
⚠️ 🐛 💡

carryxyh

💻

LICENSE

[![license][license-image]][license-url]

About

simple and fast freemarker render engine

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published