Created
December 31, 2012 02:17
-
-
Save scottraio/4416887 to your computer and use it in GitHub Desktop.
hogan templates compilation for snockets (connect-assets)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path = require('path') | |
assets = require('connect-assets') | |
hogan = require('hogan.js') | |
assets.jsCompilers.mustache = | |
namespace: "TEMPLATES" | |
match: /\.js$/ | |
compileSync: (sourcePath, source) -> | |
assetName = path.basename(sourcePath, '.mustache') | |
compiled = hogan.compile(source, asString: true) | |
"(function() { window.#{@namespace} = window.#{@namespace} || {}; window.#{@namespace}['#{assetName}'] = #{compiled}; })();" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment