Created
December 13, 2011 02:07
-
-
Save mstarkman/1470115 to your computer and use it in GitHub Desktop.
Node.js, CoffeeScript and Eco Templates
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
<%- js '/templates/index' %> |
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
assets = require 'connect-assets' | |
eco = require 'eco' | |
assets.jsCompilers.eco = | |
match: /\.eco$/ | |
compileSync: (sourcePath, source) -> | |
fileName = path.basename sourcePath, '.eco' | |
directoryName = (path.dirname sourcePath).replace "#{__dirname}/assets/templates", "" | |
jstPath = if directoryName then "#{directoryName}/#{fileName}" else fileName | |
""" | |
(function() { | |
this.JST || (this.JST = {}); | |
this.JST['#{jstPath}'] = #{eco.precompile source} | |
}).call(this); | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment