diff --git a/CHANGELOG.md b/CHANGELOG.md index aae30bd..5eb5ba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ **v0.3.0beta** (2011-07-xx): + - Added an express adapter that allows `partial 'foo'` instead of `text @partial 'foo'` (see /examples/express). + - Added id/class shortcuts (`div '#id.class.class2', 'contents'`). - Solved express integration issues and eliminated the need for a meryl adapter. diff --git a/docs/coffeekup.html b/docs/coffeekup.html index b2e1f15..317c5ad 100644 --- a/docs/coffeekup.html +++ b/docs/coffeekup.html @@ -228,9 +228,16 @@ if data.cache and cache[template]? then tpl = cache[template] else if data.cache then tpl = cache[template] = coffeekup.compile(template, data) else tpl = coffeekup.compile(template, data) - tpl(data)

Legacy adapters for a function signature of yore. Deprecated!

unless window?
-  coffeekup.adapters =
-    simple: (template, data) -> coffeekup.render template, data
-  coffeekup.adapters.meryl = coffeekup.adapters.simple
+  tpl(data)
+
+unless window?
+  coffeekup.adapters =

Legacy adapters for when CoffeeKup expected data in the context attribute.

    simple: coffeekup.render
+    meryl: coffeekup.render
+    

Allows partial 'foo' instead of text @partial 'foo'.

    express:
+      compile: (template, data) -> 
+        data.hardcode =
+          partial: ->
+            text @partial.apply @, arguments
+        coffeekup.compile(template, data)
 
 
\ No newline at end of file diff --git a/examples/express/app.coffee b/examples/express/app.coffee index f68707b..72db0f7 100644 --- a/examples/express/app.coffee +++ b/examples/express/app.coffee @@ -2,8 +2,8 @@ app = require('express').createServer() coffeekup = require '../../src/coffeekup' -app.register '.coffee', coffeekup app.set 'view engine', 'coffee' +app.register '.coffee', coffeekup.adapters.express app.get '/', (req, res) -> res.render 'index' diff --git a/examples/express/views/index.coffee b/examples/express/views/index.coffee index 613a6bc..48201b6 100644 --- a/examples/express/views/index.coffee +++ b/examples/express/views/index.coffee @@ -8,3 +8,5 @@ p 'This is the home page.' p "Let's count to 10: " p "#{i}..." for i in [1..10] + +partial 'partial', [1..10] \ No newline at end of file diff --git a/examples/express/views/partial.coffee b/examples/express/views/partial.coffee new file mode 100644 index 0000000..76a31c2 --- /dev/null +++ b/examples/express/views/partial.coffee @@ -0,0 +1 @@ +p 'Express partial' \ No newline at end of file diff --git a/src/coffeekup.coffee b/src/coffeekup.coffee index a7a7070..8fdedc5 100644 --- a/src/coffeekup.coffee +++ b/src/coffeekup.coffee @@ -288,8 +288,16 @@ coffeekup.render = (template, data = {}, options = {}) -> else tpl = coffeekup.compile(template, data) tpl(data) -# Legacy adapters for a function signature of yore. **Deprecated**! unless window? coffeekup.adapters = - simple: (template, data) -> coffeekup.render template, data - coffeekup.adapters.meryl = coffeekup.adapters.simple + # Legacy adapters for when CoffeeKup expected data in the `context` attribute. + simple: coffeekup.render + meryl: coffeekup.render + + # Allows `partial 'foo'` instead of `text @partial 'foo'`. + express: + compile: (template, data) -> + data.hardcode = + partial: -> + text @partial.apply @, arguments + coffeekup.compile(template, data) \ No newline at end of file