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

can't see values in 'outer' context when inside a loop #8

Closed
rasputnik opened this issue May 6, 2010 · 13 comments
Closed

can't see values in 'outer' context when inside a loop #8

rasputnik opened this issue May 6, 2010 · 13 comments

Comments

@rasputnik
Copy link

I've got a dead simple template and data structure.

....amended original comment with inline code and templates,
as it looked godawful....

Upshot is: Ruby Mustaches seems to DTRT, Pystache doesn't. Really hope it's a pystache bug :)

@rasputnik
Copy link
Author

Argh my eyes!

Sorry. I've stuck the sample code and templates etc up at

http://files.hellooperator.net/pystache-bug.zip

@defunkt
Copy link
Owner

defunkt commented May 7, 2010

Definitely a bug - thanks for reporting, I'll try to fix soon.

@rafacv
Copy link

rafacv commented Jul 28, 2010

This commit fixes the issue of nested contexts.

@rafacv
Copy link

rafacv commented Jul 29, 2010

The above commit has introduced a bug in which inner context propagates its data to outer context.
I added a test to expose it and now it's solved. :-)

@rafacv
Copy link

rafacv commented Aug 2, 2010

Actually, it proved to be a little more complicated than that.
I realized inner contexts checking belongs not to examples but to tests. Testing the outcome of rendering when a context is passed as a dict object - instead of a View instance - proved my previous solution was flawed.
I came to these commits which hopefully solve the issue for good.

@rasputnik
Copy link
Author

I'm embarassed to say I don't know how to install this and test ....

@rafacv
Copy link

rafacv commented Aug 6, 2010

From source:
$ wget http://download.github.com/rafaelcv-pystache-v0.3.1-15-gaa97645.zip
$ unzip rafaelcv-pystache-v0.3.1-15-gaa97645.zip
$ cd rafaelcv-pystache-aa97645/
$ nosetests
$ python setup.py install

In case you have cloned defunkt's repository, try this:
$ git remote add rafaelcv git://github.com/rafaelcv/pystache.git
$ git remote update rafaelcv
$ git checkout rafaelcv/master -b nestedcontexts
$ nosetests
$ python setup.py install

@defunkt
Copy link
Owner

defunkt commented Aug 9, 2010

Did you forget to commit examples/inner_context_bubbling.py?

@rafacv
Copy link

rafacv commented Aug 10, 2010

Oops, what I forgot was to remove the import. Since I got inner_context_bubbling.pyc file in examples directory, import was reaching the thing and tests passed. Sorry about that.

Fixed; overall changes presented in this compare view.

@rasputnik
Copy link
Author

Doesn't seem to work (using 217efd4).

  • the files.hellooperator.net link is working again now, if you want to see what I'm trying to do.

@rafacv
Copy link

rafacv commented Aug 10, 2010

Indeed. Nested contexts were working only for non-looping blocks. Extended to looping ones too.
Tests still failing because of whitespace issue though.

@cjerdonek
Copy link
Collaborator

Will be taking a look at this. Here is the test case in the zip file included in one of the first comments above:

Context:

{ "greeting": "hello",
  "list": [
    {"name": "eeny"},
    {"name": "meeny"},
    {"name": "miney"},
    {"name": "mo"}
  ]
}

Template:

Say '{{greeting}}', everyone:

{{#list}}
  {{name}} says: {{ greeting}}
{{/list}}

cjerdonek added a commit that referenced this issue Dec 19, 2011
Added a unit test to show that the issue is no longer present:
section list items do have access to the parent context.
@cjerdonek
Copy link
Collaborator

This must have gotten fixed somewhere along the way. Seems to be fixed in master as well.

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

4 participants