Handlebars.js: Stream support?

Created on 12 Dec 2015  ·  7Comments  ·  Source: handlebars-lang/handlebars.js

Would be nice if it could parse chunks.

Most helpful comment

With streaming coming to the client & service worker, this may be worth revisiting?https://jakearchibald.com/2016/streams-ftw/#creating-one-stream-from-multiple-sources-to-supercharge-page-render-times

Also, dustjs was of real benefit when I built https://wiki-offline.jakearchibald.com/ (explaination https://www.youtube.com/watch?v=d5_6yHixpsQ&feature=youtu.be&t=4m22s), since some of my data was slower to arrive and I wanted a fast first render.

Dustjs handles promises & streams as template values, but unfortunately I have nothing nice to say about dustjs's syntax.

All 7 comments

It's not exactly clear what this would entail or what the benefit would be. What is your use case?

Faster parsing via file/http stream input. A use case could be build scripts and/or compatibility with gulp.

Reading the template is not the slow part of the compilation pipeline, it's the actual parsing and if you're putting in template that are large enough that you have concerns about the IO wait time or the cost of loading the template into memory prior to parsing, I'd start to wonder if there is too much data hard coded in the template.

That and our parser generator does not support a stream mode so the cost/benefit here doesn't really work out in my head.

With a stream, many templates could be parsed concurrently with less memory consumption and garbage collection because the template string never ends up in memory.

It's a micro-optimization at best, if you are pushing megabytes of
templates into the parser, your going to see more issues from being CPU
bound in the parser itself.

If someone from the community were to investigate, we might consider
accepting it, but I fear that would basically be a full rewrite of the
parser.

On Fri, Dec 11, 2015 at 9:23 PM Steven Vachon [email protected]
wrote:

With a stream, many templates could be parsed concurrently with less
memory consumption and garbage collection.


Reply to this email directly or view it on GitHub
https://github.com/wycats/handlebars.js/issues/1150#issuecomment-164105284
.

With streaming coming to the client & service worker, this may be worth revisiting?https://jakearchibald.com/2016/streams-ftw/#creating-one-stream-from-multiple-sources-to-supercharge-page-render-times

Also, dustjs was of real benefit when I built https://wiki-offline.jakearchibald.com/ (explaination https://www.youtube.com/watch?v=d5_6yHixpsQ&feature=youtu.be&t=4m22s), since some of my data was slower to arrive and I wanted a fast first render.

Dustjs handles promises & streams as template values, but unfortunately I have nothing nice to say about dustjs's syntax.

One more resource to add to the list: https://jakearchibald.com/2016/streaming-template-literals/ (it links to this issue)

Was this page helpful?
0 / 5 - 0 ratings