npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ftl2html

v1.2.0

Published

covert freemarker template(ftl) to html by fmpp

Downloads

63

Readme

ftl2html

ftl2html is a clean, just one dependency Node.js module invoke fmpp convert freemarker and data to html.

You need to Install Java Runtime Environment(JRE) 1.7+ first.

Build Status Coverage Status Dependency Status NPM version

Installation

via npm:

$ npm install ftl2html

example

ftlPath:

/test/_src/normal.ftl
/test/_src/parseObj.ftl

tddPath:

/test/_tdd/normal.tdd
/test/_tdd/parseObj.tdd

targetPath:

/test/_target/

just run:

var f = new ftl2html({
    sourceRoot: "_src",
    dataRoot: "_tdd",
    outputRoot: "_target"
});

f.render({
    ftlFile: "/**/*.ftl",
    callback: function (error, stdout, stderr, fileName) {
        console.log(fileName + " is done");
    },
    done: function() {
        console.log("Everything is done");
    }
});

it will do find the match one and compile it, then put it into targetPath. if you want extra tdd file(relative to tddPath), you can add it's path(string or Array) when you call render. like :

f.render({
    ftlFile: "/**/*.ftl",
    tddFiles: "./extra.tdd"
});

API

recommand usage:

just setup sourceRoot and dataRoot. it will find the same fileName in these path and covert it, more example in test.

var f = new ftl2html(initConfig);

initConfig parameter:

  • sourceRoot: freemarker template folder path (require)
  • dataRoot: mock data folder path (require)
  • outputRoot: save converted html path (require)
  • isDebug: set true will print every fmpp command before execute, default is false
  • javaPath: use specify java if you need, default is "java"
  • jarPath: use specify fmpp.jar if you need, default is jar in module
  • async: convert ftl async or not, default is true
  • tddFiles: common tdd file for all ftl convert
  • logFile: fmpp convert log, default is none
  • configFile: any extra fmpp config

f.render({
    ftlFile: "./normal.ftl",
    callback: function(error, stdout, stderr, fileName) {
        console.log(fileName + " is done");
    },
    done: function() {
        console.log("Everything is done");
    }
});
  • ftlFile: covert ftl file name, relative to sourceRoot
  • callback: every ftl coverted will be call
  • done: all ftl coverted will be call

render method will extend it's config with initConfig, any common config should be put in initConfig.

compatible usage:

for some old project, won't update.

var ftl2html = require('ftl2html');

// compile
ftl2html(ftlPath, outputPath, ftlFileName, tddFiles, logFile);
  • ftlPath: freemarker template file path
  • outputPath: convert to html save path
  • ftlFileName: freemarker template file name, relative to ftlPath
  • tddFiles: mock data file(reference fmpp manual)
  • logFile: fmpp convert log, default is none

extend freemarker syntax

var user = ${JSONObject.fromObject(userObj)};
var fids = ${JSONArray.fromObject(userArr)};

Syntax

It just like freemarker syntax with a little extend. Here is a simple example:

<i>${test1}</i><i>${test2!"no"}</i><i>${common}</i>

combine data

{
    "test1": "test1",
    "common": "common"
}

become

<i>test1</i><i>no</i><i>common</i>

Node.js Support

4+

Manual

Freemarker Manual

Fmpp Manual

License

MIT