Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
HTML templates in pure CoffeeScript
CoffeeScript
Branch: WM_css
Pull request Compare This branch is 27 commits behind master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
src
.gitignore
.npmignore
CHANGELOG
Cakefile
LICENSE
README.md
benchmark.coffee
package.json
profile.coffee
test.coffee

README.md

CoffeeMugg

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.

Sample

Basic example:

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

With subroutines:

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

template = ->
  @div ->
    @myroutine()

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"]

Installation

npm install coffeemugg

Cli

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

coffeemugg -h

Usage:
  coffeemugg [options] path/to/template.coffee

  -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

More

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

Special thanks

Something went wrong with that request. Please try again.