hogan.jsx

0.1.2 • Public • Published

hogan.jsx

Synopsis

This is a JSX version of JavaScript templating library Hogan. Original Hogan and this Hogan.jsx implement Mustache template syntax. You can read detail syntax at here.

This project is aming following features:

  • Genrerate JS Function object
  • Genrerate JSX script from Mustache formating templates (not tested yet).

Code Example

import "console.jsx";
import "hogan.jsx";
 
class _Main {
    static function main (argv : string[]) : void
    {
        var data = {
            weather: "a sunny day!",
        } : variant;
 
        var template = Hogan.compile("Today's weather is {{weather}}");
        var output = template.render(data);
        // prints "Today's wheather is a sunny day!"
        console.log(output);
    }
}

Installation

$ npm install hogan.jsx

API Reference

  • static Hogan.compile(src : string) : Template

    Generate Template object.

  • static Hogan.compileToJSX(src : string) : string

    Generate Template instance source code in JSX.

  • Template.render(context : variant) : string

    Generate converted text.

Development

Repository

Run Test

$ grunt test

Build

# Generate API reference 
$ grunt doc
 
# Build application or library for JS project 
$ grunt build

Author

License

MIT

Complete license is written in LICENSE.md.

Original License

Copyright 2011 Twitter, Inc.

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

Package Sidebar

Install

npm i hogan.jsx

Weekly Downloads

5

Version

0.1.2

License

MIT

Last publish

Collaborators

  • shibu