Closed fjbsantiago closed 12 years ago
You can call toffee to render a template whenever you want in Node. For example, you could pre-pub a partial and have the results of that call pubbed/cached in a variable if you wanted. If I understand what you're asking correctly, just use toffee.render
, which expects 3 arguments:
For example:
toffee = require('toffee')
toffee.render '/partials/somePartial.toffee', {foo: "bar"}, (err, res) ->
# do something with err, res
You could then take that res
variable and pub that into your final page, if you wanted to. Or do whatever else you wanted with it.
Does that answer your question?
Yes it does Mr. Chris! Thank you. Lazy me, not making an effort and searching.
That's it
Great! I'm going to try to update the docs to make this clearer.
Hi Chris!
What if it were possible, on demand, before calling "res.render", to require and call Toffee, giving it the path to a partial, so Toffee could render it and return the result as a string.
This would make it possible, for example, to request html partials dinamically from the client, without having to hammer the html it in javascript.
Example of complete page request:
routes.coffee
layout.toffee
Now, if an ajax request came in asking for alertMessagePartial
How cool would this be? Then, on client side, we would just have to clear the main body container and replace it with the returned html !
Do you think this is doable?