yeoman-hoganjs-engine
v0.0.5
Published
Hogan.js templating engine for Yeoman using Underscore helpers
Downloads
23
Maintainers
Readme
yeoman-hoganjs-engine
Hogan.js templating engine with Underscore.string support for Yeoman.
> npm install yeoman-hoganjs-engine
Adding Hogan.js engine to your Yeoman generator
var HulkHoganGenerator = yeoman.generators.NamedBase.extend({
engine: require('yeoman-hoganjs-engine')(), // or set your delimiters: require('yeoman-hoganjs-engine')('<%=', '%>')
constructor: function(args, opts, config) {
yeoman.generators.NamedBase.apply(this, args, opts);
},
...
};
Using it!
Inside your generator template
Follow us at
{{#tweets}}
<a href="http://twitter.com/{{name}}/>@{{name}}</a>
{{/tweets}}
Inside your generator action
...
writing: function () {
this.tweets = [
{ name: 'michaelwolbert' },
{ name: 'hoganjs' },
{ name: 'yeoman' }
];
this.template('_template.hogan', 'template.html');
}
...
Using Underscore.string
{{#classify}}{{myClass}}{{/classify}}
If myClass = 'myClass', then the above template would output MyClass. See below for supported Underscore.string functions.
Underscore.string
Supported functions
- isBlank
- stripTags
- capitalize
- clean
- chars
- swapCase
- escapeHTML
- unescapeHTML
- escapeRegExp
- join (Array based)
- lines
- reverse
- succ
- titleize
- camelize
- underscored
- dasherize
- classify
- humanize
- trim
- ltrim
- rtrim
- words
- slugify
- quote || q
- unquote
- strip
- lstrip
- rstrip
Unsupported functions
- chop
- count
- splice
- insert
- include
- startsWith
- endsWith
- pad
- lpad
- rpad
- lrpad
- sprintf
- vsprintf
- toNumber
- numberFormat
- strRight
- strRightBack
- strLeft
- strLeftBack
- toSentence
- toSentenceSerial
- surround
- exports
- repeat
- naturalCmp
- levenshtein
- toBoolean
- center
- rjust
- ljust
- toBool