Skip to content

Instantly share code, notes, and snippets.

@paul-english
Created March 26, 2012 17:14
Show Gist options
  • Save paul-english/2206581 to your computer and use it in GitHub Desktop.
Save paul-english/2206581 to your computer and use it in GitHub Desktop.
trick to make eco templates work well with asset pipeline
# Client side eco templating
assets.jsCompilers.eco =
match: /\.eco$/
compileSync: (sourcePath, source) ->
fileName = path.basename sourcePath, '.eco'
directoryName = (path.dirname sourcePath).replace "#{__dirname}/public/js/templates", ""
jstPath = if directoryName then "#{directoryName}/#{fileName}" else "/#{fileName}"
"(function() {window.JST || (window.JST = {});window.JST['#{jstPath}'] = #{eco.precompile source}}).call(this);"
app.set 'view engine', 'eco'
app.set 'views', __dirname + '/public/js/templates'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment