Skip to content
Newer
Older
100644 78 lines (56 sloc) 2.15 KB
13a0da0 @jaekwon readme
authored
1 CoffeeMugg
2 ==========
3
6ca260b .
Jae Kwon authored
4 CoffeeMugg is a templating engine for [node.js](http://nodejs.org) and browsers that lets you to write your HTML templates in 100% pure [CoffeeScript](http://coffeescript.org).
01d95af @jaekwon .
authored
5
6ca260b .
Jae Kwon authored
6 CoffeeMugg is a branch of [CoffeeKup](https://github.com/mauricemach/coffeekup). The main difference is that instead of local tag functions, tag functions are bound to `this`.
7
e48fa8f @jaekwon Update README.md
authored
8 ## Why CoffeeMugg?
6ca260b .
Jae Kwon authored
9
2227657 @jaekwon updated readme
authored
10 * No magic compilation step: the template code runs as you would expect.
e48fa8f @jaekwon Update README.md
authored
11 * Local variables obey original Javascript/Coffeescript rules.
12 * If you want to create a template dynamically using function closures, you can!
2227657 @jaekwon updated readme
authored
13 * This makes it easier to create libraries of view-helper routines, in the manner of RoR ActionView.
6ca260b .
Jae Kwon authored
14
e48fa8f @jaekwon Update README.md
authored
15 ## Sample
13a0da0 @jaekwon readme
authored
16
2227657 @jaekwon updated readme
authored
17 Basic example:
18 ```coffeescript
19 coffeemugg.render ->
20 @div ->
21 @p "I am a paragraph"
22 ```
23
24 With subroutines:
25 ```coffeescript
26 subroutines = {
27 myroutine: ->
28 @p 'blah blah'
29 }
30
31 template = ->
32 @div ->
33 @myroutine()
34
35 coffeemugg.render template, {context: subroutines}
36 ```
37
38 With arguments:
39 ```coffeescript
e48fa8f @jaekwon Update README.md
authored
40 template = (div_id, contents) ->
41 @div id:div_id, ->
42 for content in contents
43 @div content
6ca260b .
Jae Kwon authored
44
e48fa8f @jaekwon Update README.md
authored
45 coffeemugg.render template, <OPTIONS>, "FRUITS", ["Apple", "Banana", "Raisin"]
2227657 @jaekwon updated readme
authored
46 ```
6ca260b .
Jae Kwon authored
47
e48fa8f @jaekwon Update README.md
authored
48 ## Installation
9fa13a2 added install message
Jae Kwon authored
49
50 npm install coffeemugg
e48fa8f @jaekwon Update README.md
authored
51
52 ## Cli
9fa13a2 added install message
Jae Kwon authored
53
e48fa8f @jaekwon Update README.md
authored
54 Create static html files in CoffeeMugg syntax. It's adapted from coffeecup.
55 ```
56 coffeemugg -h
57
58 Usage:
59 coffeemugg [options] path/to/template.coffee
60
61 -w, --watch watch templates for changes, and recompile
62 -o, --output set the directory for compiled html
63 -p, --print print the compiled html to stdout, don't write file
64 -f, --format apply line breaks and indentation to html output
65 -v, --version display coffeemugg version
66 -h, --help display this help message
67 ```
68
69 ## More
6ca260b .
Jae Kwon authored
70
71 Please take a look at the excellent [CoffeeScript](http://coffeescript.org) documentation for more information.
72
e48fa8f @jaekwon Update README.md
authored
73 ## Special thanks
55c1489 .
Jae Kwon authored
74
75 - [Jeremy Ashkenas](https://github.com/jashkenas), for the amazing CoffeeScript language.
6ca260b .
Jae Kwon authored
76 - [Maurice Machado](https://github.com/mauricemach), for CoffeeKup. Hope you're OK with this.
e48fa8f @jaekwon Update README.md
authored
77 - [W. Mertens](https://github.com/wmertens), for the latest contributions.
Something went wrong with that request. Please try again.