Skip to content

Instantly share code, notes, and snippets.

@scottraio
Created December 31, 2012 02:17
Show Gist options
  • Save scottraio/4416887 to your computer and use it in GitHub Desktop.
Save scottraio/4416887 to your computer and use it in GitHub Desktop.
hogan templates compilation for snockets (connect-assets)
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