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

Helper is not scoped to request, but to app #10

Closed
bengourley opened this issue May 23, 2012 · 0 comments
Closed

Helper is not scoped to request, but to app #10

bengourley opened this issue May 23, 2012 · 0 comments

Comments

@bengourley
Copy link
Contributor

The helpers compactJsHtml() and compactJs() are attached to app.helpers, which means that they exist for the duration of the application, not the request (as expected).

Here is a problem that is causes:

app.js

app.get('/', routes.index); // No JS on page
app.get('/edit', compact.js(['edit']), routes.edit); // `edit` JS on the page

layout.jade (inherited by index and edit views)

//...
if (compactJsHtml !== 'undefined')
  !=compactJsHtml()
//...
  • If you view / then the page is output as desired: no JS.
  • If you view /edit then the page is output as desired: edit JS
  • Subsequent views to / output the edit JS because compactJsHtml is still defined from the request to
    /edit
bengourley added a commit to bengourley/compact that referenced this issue Jul 5, 2012
@serby serby closed this as completed Jul 7, 2012
serby pushed a commit that referenced this issue Jul 7, 2012
Support for Express 2.x and 3.x (fixes #14), also fixes #10
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