Skip to content

Instantly share code, notes, and snippets.

@klclee
Created May 24, 2013 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klclee/5642533 to your computer and use it in GitHub Desktop.
Save klclee/5642533 to your computer and use it in GitHub Desktop.
This is originally from @williamcoates on github but fix some stuff so it works.
hbs = require 'hbs'
#for css
hbs.registerHelper 'css', (file, media) ->
media = "all" unless media.substring?
st = ''
require('xml2js').parseString css(file), (err, xml) ->
st = """<link href="#{xml.link.$.href}" media="#{media}" rel="stylesheet" type="text/css"/>"""
st
#for js
hbs.registerHelper 'js', (path) ->
js(path)
#for images
hbs.registerHelper 'img', (file) ->
"""<img src="#{img(file)}"/>"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment