Asynchronous Template Engine

32 views
Skip to first unread message

Malte Ubl

unread,
Dec 27, 2009, 7:15:32 AM12/27/09
to nod...@googlegroups.com
Hey,

just wanted to let you know about a little extention I build upon the
regular ERB-style templating that is available through underscore.js
and other libraries.

The template engine can execute parts asynchronously. The usefulness
of this might be kind of limited but it does help with flushing
content to the browser as early as possible. It basically means that
you can execute the view at the same time as the model.

Example Template
http://paste.ubuntu.com/346640/

Source
http://bit.ly/7sLQkY

Cheers
Malte

--
http://twitter.com/cramforce
http://nonblocking.io

Felix Geisendörfer

unread,
Dec 27, 2009, 8:02:03 AM12/27/09
to nodejs
That's really cool! I was wondering how this could be done for a while
and your solution to it is very nice.

I really think async templating should become standard in the node
world.

--fg

Serge in Darkness

unread,
Dec 28, 2009, 7:22:56 AM12/28/09
to nodejs
This looks really promising :)

On Dec 27, 3:15 pm, Malte Ubl <malte....@gmail.com> wrote:
> Hey,
>
> just wanted to let you know about a little extention I build upon the
> regular ERB-style templating that is available through underscore.js
> and other libraries.
>
> The template engine can execute parts asynchronously. The usefulness
> of this might be kind of limited but it does help with flushing
> content to the browser as early as possible. It basically means that
> you can execute the view at the same time as the model.
>

Malte Ubl

unread,
Dec 28, 2009, 5:50:49 PM12/28/09
to nod...@googlegroups.com
I implemented
- nested asynchronous partials
- optional hot code reloading
- multi line <%%> statements

Currently partials are not streamed before completion of the partial.
I might change this.

Next up is a release on github.

Cheers
Malte

> --
>
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

Tim Caswell

unread,
Dec 28, 2009, 6:02:30 PM12/28/09
to nod...@googlegroups.com
I'm working on a framework for async templating engines. I'm going to experiment with the ideas in Temple <http://judofyr.net/posts/temple.html>. I've had feature requests in my haml port for partials. This can't be done in a synchronous way since file IO is async.

I'll probably have something posted on Github in the next day or too. For now the project will called Grain. <http://bit.ly/7rL7h1>

Felix Geisendörfer

unread,
Dec 29, 2009, 5:17:51 AM12/29/09
to nodejs
On Dec 28, 11:50 pm, Malte Ubl <malte....@gmail.com> wrote:
> I implemented
> - nested asynchronous partials
> - optional hot code reloading
> - multi line <%%> statements

What do you mean with hot code reloading?

--fg

Malte Ubl

unread,
Dec 29, 2009, 6:16:53 AM12/29/09
to nod...@googlegroups.com
Hey,

2009/12/29 Felix Geisendörfer <fe...@debuggable.com>:


> On Dec 28, 11:50 pm, Malte Ubl <malte....@gmail.com> wrote:
>> I implemented
>> - nested asynchronous partials
>> - optional hot code reloading
>> - multi line <%%> statements
>
> What do you mean with hot code reloading?

if the template changes on the server it is recompiled and loaded into memory.

Cheers
Malte

Felix Geisendörfer

unread,
Dec 29, 2009, 8:23:14 AM12/29/09
to nodejs
> > What do you mean with hot code reloading?
>
> On Dec 29, 12:16 pm, Malte Ubl <malte....@gmail.com> wrote:
> if the template changes on the server it is recompiled and loaded into memory.

Very nice! Can't wait to play with this soon! Hopefully Ryan will like
my hot-code reloading stuff for modules as well, but gotta figure out
this libeio issue first!

--fg

Malte Ubl

unread,
Dec 29, 2009, 2:46:30 PM12/29/09
to nod...@googlegroups.com
I release the code with some examples and docs to GitHub
http://github.com/cramforce/node-asyncEJS

Cheers
Malte

2009/12/29 Felix Geisendörfer <fe...@debuggable.com>:

Tim Caswell

unread,
Dec 29, 2009, 2:54:30 PM12/29/09
to nod...@googlegroups.com
Awesome stuff, do you mind if I steal some ideas for my Grain framework?

Malte Ubl

unread,
Dec 29, 2009, 2:56:25 PM12/29/09
to nod...@googlegroups.com
On Tue, Dec 29, 2009 at 8:54 PM, Tim Caswell <t...@creationix.com> wrote:
> Awesome stuff, do you mind if I steal some ideas for my Grain framework?

Fork away!

Reply all
Reply to author
Forward
0 new messages