0.1.9 • Published 2 years ago
bigotes v0.1.9
Bigotes
This is a simple re-implementation of Mustache with direct support for internationalization (i18n-style). It can be used directly as a view engine in Express:
var bigotes = require('bigotes');
app.engine ("bgt",bigotes); // files with ".bgt" extension are rendered by Bigotes
It can also be used without a view engine, by calling .compile:
var bigotes = require('bigotes');
var str = "Hello, {{name}}!";
var template = bigotes.compile (str); // compiles mustache string into a Javascript function
var text = template ( {name:"John"} ); // (the javascript function takes data as argument)
console.log(text); // displays: Hello, John!
I18n-style internationalization is supported directly, by using double-quotes:
var bigotes = require('bigotes');
var str = '{{"Hello"}}, {{name}}!';
var template = bigotes.compile (str);
var text = template ( {name:"John"}, i18n ); // where i18n is some object with a "__" method.
console.log(text); // displays: Hola, John!