I use eco templates and stitch.

I keep the templates in app/templates
In express, I app.use("app/templates") and res.render("foo", data)
Stitch pre-compiles everything in app to javascript functions,
including eco templates
In the client, I template = require("templates/foo"); template(data)

You could do the same with requireJS, but I'm quite fond of stitch's simplicity.

The whole setup is quite simple and works. Obviously, I can't make use
of express features such as partial in my templates. I share helper
functions in a similar manner (they're at app/helpers, so
require("helpers") in the client and
app.helpers(require("app/helpers")) in Express).

On Wed, Mar 7, 2012 at 23:52, Dave Elkan <[email protected]> wrote:
> Alexey,
>
> That's what the solution I describe above does. Except it doesn't simply
> include the template into the HTML, but pre-compiles them down to javascript
> functions which can be run in the the browser. This could be included as an
> inline script or a remote script reference.
>
>
> On Wed, Mar 7, 2012 at 9:48 PM, Alexey Petrushin
> <[email protected]> wrote:
>>>
>>> If I'm understand right the whole point of question is not how to share
>>> templates with client, but how to do it EFFICIENTLY.
>>>
>>> You probably will not do it by loading templates on the client one by one
>>> because speed and responsiveness of the Client will be terrible.
>>>
>>> I'm facing similar problem, it seems that the simplest way is just write
>>> a custom node script that will crawl Your 'app/views' directory on the
>>> server-side and include every template from there into the Client's HTML
>>> page.
>>>
>>> It would be nice if Asset Management solutions somehow automate this
>>> problem, but it seems that they don't (at least I don't know about it).
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>
>
>
>
> --
> http://www.edave.net
> https://github.com/dave-elkan
> Twitter: @edave
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en



-- 
Linus G Thiel
Hansson & Larsson
http://hanssonlarsson.se/
+46 709 89 03 85

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to