coffeemugg
HTML templating with CoffeeScript.
Last updated 7 years ago .
Repository · Original npm · Tarball · package.json
$ cnpm install coffeemugg 
SYNC missed versions from official npm registry.

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?

  • First, a disclaimer: I can't vouch for the usefulness of this branch just yet.
  • I believe this makes it easier to create libraries of view-helper routines, in the manner of RoR ActionView.
  • CoffeeMugg is easier to grok than CoffeeKup, since it's straight up Javascript/Coffeescript without an intermediate compilation step, and local variables obey original Javascript/Coffeescript rules. If you want to create a template dynamically using function closures, why go ahead.
  • There is no compilation step, so rendering on the client may be faster.

Sample

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

with subroutines:

# Create a new class with all the subroutines
MyContext = CMContext.extend({
  myroutine: ->
    @p 'blah blah'
})

# Create a rendering instance
context = new MyContext()
context.render ->
  @div ->
    @myroutine()

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

More

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

Special thanks

Current Tags

  • 0.0.8                                ...           latest (7 years ago)

8 Versions

  • 0.0.8                                ...           7 years ago
  • 0.0.7                                ...           7 years ago
  • 0.0.6                                ...           7 years ago
  • 0.0.5                                ...           8 years ago
  • 0.0.4                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |