Skip to content

Instantly share code, notes, and snippets.

@mstarkman
Created December 13, 2011 02:07
Show Gist options
  • Save mstarkman/1470115 to your computer and use it in GitHub Desktop.
Save mstarkman/1470115 to your computer and use it in GitHub Desktop.
Node.js, CoffeeScript and Eco Templates
<%- js '/templates/index' %>
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