Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

revised coffeekup example due to latest coffeekup improvements

  • Loading branch information...
commit 22bbfef4f027ad430cca37831e762be6bdbe0d9a 1 parent 204d9b1
@kadirpekel authored
View
10 examples/coffeekup/app.coffee
@@ -5,14 +5,10 @@ mate = require '../../lib/coffeemate'
mate.options.renderExt = '.coffeekup'
mate.options.renderDir = 'views'
-# bind coffeekup explicitly
-mate.options.renderFunc = (tmpl, ctx) ->
- coffeekup.render tmpl, context: ctx
-# or use the shortcut sugar below
-# mate.coffeekup()
+# Bind coffeekup with an helper
-mate.context.highlight = (msg) ->
- "<span style=\"background-color:#ff0\">#{msg}</span>"
+mate.coffeekup highlight: (color, msg) ->
+ text "<span style=\"background-color:#{color}\">#{msg}</span>"
mate.get '/', ->
@foo = 'bar'
View
6 examples/coffeekup/views/main.coffeekup
@@ -1,5 +1,7 @@
html ->
head
body ->
- h1 "Kup of coffee"
- div @highlight @foo
+ h1 "A cup of coffee demonstration"
+ include "nested1"
+ include "nested2"
+ include "nested3"
View
2  examples/coffeekup/views/nested1.coffeekup
@@ -0,0 +1,2 @@
+p ->
+ highlight "#0ff", "This is a highlighted text"
View
2  examples/coffeekup/views/nested2.coffeekup
@@ -0,0 +1,2 @@
+p ->
+ highlight "#f00", "This is a highlighted text"
View
2  examples/coffeekup/views/nested3.coffeekup
@@ -0,0 +1,2 @@
+p ->
+ highlight "#ff0", "This is a highlighted text"
Please sign in to comment.
Something went wrong with that request. Please try again.