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

Providing context to a partial prevents other included partials from accessing that context #81

Open
paulyoung opened this issue Jul 30, 2014 · 1 comment

Comments

@paulyoung
Copy link

Scenario 1: without passing context to a partial

bar.ect

<% include 'foo' %>
<%- JSON.stringify @, null, 2 %>

foo.ect

<% @foo = 'foo' %>

page.ect

<% include 'bar' %>

output

{
  "foo": "foo"
}

Scenario 2: passing context to a partial

bar.ect

<% include 'foo' %>
<%- JSON.stringify @, null, 2 %>

foo.ect

<% @foo = 'foo' %>

page.ect

<% include 'bar', { baz: 'baz' } %>

output

{
  "baz": "baz"
}

Here, I would expect the context to be mixed in, and the output to be:

{
  "foo": "foo",
  "baz": "baz"
}
@paulyoung
Copy link
Author

For anyone else experiencing this issue, my workaround is to pass @ to the included partial:

bar.ect

<% include 'foo', @ %>
<%- JSON.stringify @, null, 2 %>

output

{
  "foo": "foo",
  "baz": "baz"
}

@paulyoung paulyoung changed the title Providing context to a partial prevents other mixins from accessing that context Providing context to a partial prevents other included partials from accessing that context Jul 30, 2014
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