Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming? #21

Closed
JacobEvelyn opened this issue Feb 20, 2012 · 2 comments
Closed

Streaming? #21

JacobEvelyn opened this issue Feb 20, 2012 · 2 comments

Comments

@JacobEvelyn
Copy link

The readme says "streaming friendly," but I can't seem to see how in the code that would be possible. I'm pretty new to node and js so I'm sure I could just be overlooking something...

@olado
Copy link
Owner

olado commented Feb 20, 2012

By streaming friendly I meant that you can write out partial results during template rendering.

Say you have to iterate over a big result set in your template and produce a list. With doT you can write out each list item (or a batch of several items) as you go (vs engines that do push/join for example).
To do it you would write the content of 'out' variable out, and reset 'out' variable to an empty string, like this (say you passed response object to the template function):

{{ your iterator here { }}
/* list item template here */

  • {{=item.name}}
  • /* flush out and reset */
    {{ it.response.write(out); out=""; }}
    

    {{ } }}

    Laura

    On 2012-02-20, at 1:35 PM, ConstableJoe wrote:

    The readme says "streaming friendly," but I can't seem to see how in the code that would be possible. I'm pretty new to node and js so I'm sure I could just be overlooking something...


    Reply to this email directly or view it on GitHub:
    #21

    @JacobEvelyn
    Copy link
    Author

    Ah, cool. Thanks for the quick response.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants