Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (56 sloc) 2.15 KB


CoffeeMugg is a templating engine for node.js and browsers that lets you to write your HTML templates in 100% pure CoffeeScript.

CoffeeMugg is a branch of CoffeeKup. The main difference is that instead of local tag functions, tag functions are bound to this.

Why CoffeeMugg?

  • No magic compilation step: the template code runs as you would expect.
  • Local variables obey original Javascript/Coffeescript rules.
  • If you want to create a template dynamically using function closures, you can!
  • This makes it easier to create libraries of view-helper routines, in the manner of RoR ActionView.


Basic example:

coffeemugg.render ->
  @div ->
    @p "I am a paragraph"

With subroutines:

subroutines = {
  myroutine: ->
    @p 'blah blah'

template = ->
  @div ->

coffeemugg.render template, {context: subroutines}

With arguments:

template = (div_id, contents) ->
  @div id:div_id, ->
    for content in contents
      @div content

coffeemugg.render template, <OPTIONS>, "FRUITS", ["Apple", "Banana", "Raisin"]


npm install coffeemugg


Create static html files in CoffeeMugg syntax. It's adapted from coffeecup.

coffeemugg -h

  coffeemugg [options] path/to/

  -w, --watch        watch templates for changes, and recompile
  -o, --output       set the directory for compiled html
  -p, --print        print the compiled html to stdout, don't write file
  -f, --format       apply line breaks and indentation to html output
  -v, --version      display coffeemugg version
  -h, --help         display this help message


Please take a look at the excellent CoffeeScript documentation for more information.

Special thanks

Jump to Line
Something went wrong with that request. Please try again.