Created
March 26, 2012 17:14
-
-
Save paul-english/2206581 to your computer and use it in GitHub Desktop.
trick to make eco templates work well with asset pipeline
This file contains 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
# 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