pthrasher / snockets

Sprockets-style script concatenation for Node
119 stars 39 forks source link

Pass assetName argument to compileSync method #11

Open umairsiddique opened 12 years ago

umairsiddique commented 12 years ago

So, instead of

compileSync: (sourcePath, source) ->

We will have

compileSync: (sourcePath, source, assetName) ->

This would be of particular use for adding compilers for template engines.

For example, I would be able to do this.

assets.jsCompilers.mustache =
  namespace: "TEMPLATES"
  match: /\.js$/
  compileSync: (sourcePath, source, assetName) ->
    compiled = hogan.compile(source, asString: true)
    "(function() { window.#{@namespace} = window.#{@namespace} || {}; window.#{@namespace}['#{assetName}'] = #{compiled}; })();"
alexkwolfe commented 12 years ago

+1

pthrasher commented 11 years ago

Interesting idea. I've got a few ideas on how to approach this. I'll give it some thought for the upcoming 2.0 release.