tj / ejs

Embedded JavaScript templates for node
4.47k stars 512 forks source link

Unbuffered data not rendered on view from callback. #152

Open ArkeologeN opened 10 years ago

ArkeologeN commented 10 years ago

I've registered an object in app.locals and then accessing it in my layout view. The object is available and it accepts callback function as the argument due to async nature.

My snippet is:

<% flash(function(msgs) { %>
    <% for(var type in msgs) { %>
        <div class="alert alert-<%= type %>"><%= msgs[type] %></div>
        <% console.log(msgs[type]) %>
    <% } %>
<% }); %>

flash object is all available and it also outputs data in console.log but unfortunately doesn't render <div> element on web page. I tried adding - or = with opening marks but failed.

Seems something wrong in ejs while dealing the output from callback function

TimothyGu commented 9 years ago

Can you paste the error you are seeing?