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

Something seems to be "eating" my locals! #504

Closed
ghost opened this issue Jan 15, 2011 · 5 comments
Closed

Something seems to be "eating" my locals! #504

ghost opened this issue Jan 15, 2011 · 5 comments

Comments

@ghost
Copy link

ghost commented Jan 15, 2011

I am passing them in but the ServerResponse.view.render() method eats them before I render!
This is a recent problem - this was not working wrong before the last week or so.

I managed to "patch" the view.render method to re-enable my locals but something in between where I'm saving them and where I'm re-inserting them is destroying the local variable namespace.

My patched version of the view.render method is at https://gist.github.com/781377#comments

@tj
Copy link
Member

tj commented Jan 15, 2011

hmm, possibly the new res.local() merge is messing things up, tests and examples seem fine though, can you more info so I can reproduce?

@ghost
Copy link
Author

ghost commented Jan 16, 2011

The calling routine:

                        res.render('content/index.html', {
                            locals: {
                                foo: 'fooval',
                                contents: a,
                                form: form
                            }
                        });

The template:

Content Repositories

<% if (false && contents) { %>

<% for(var prop in contents){ var content = contents[prop]; %>
<%- content.name %>
<%- content.url %>
<%} %>

<% } else { %>

-- no content

<% } %>

Add Domain

<%- form.render() %>

Foo: <%- foo %>

@ghost
Copy link
Author

ghost commented Jan 16, 2011

(and for test purposes I erased all but the last line of the template)

As my gist demonstrates I validated that at the beginning of the view/render routine my local variables were present and by the time the code reached

//Attempt Render

my local variables were not evident.

I have not triangulated the part of http.ServerResponse.prototype.render that "eats" my locals but it is somewhere between those two points.

@tj
Copy link
Member

tj commented Jan 17, 2011

hmm, the gist has code from master (2.x), but you use locals: {} ? from 1.x

@tj
Copy link
Member

tj commented Mar 2, 2011

seems fine to me, closing for now

This issue was closed.
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

1 participant