-
Notifications
You must be signed in to change notification settings - Fork 71
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
Proposal: Limiting context when using implicit iterators #10
Comments
Obviously, the advice commonly given for this problem is either "change the name of your page title attribute" or "normalize your stylesheet objects so that they share common keys" -- and while these are generally good guidelines, it isn't a particularly friendly answer for a relatively common case. |
Shameless plug, but the strawman for M2 addresses this: http://writing.jan.io/mustache-2.0.html |
@leth Theoretically, template data is always entirely under your control and any issues like this have understood workarounds. In practice, that's just a dumb assumption. There are actually two problems to solve here, and only one actually has a reasonable solution:
The first problem would be simply solved if we had opted to use a character other than The second problem stems from the fact that we don't permit arbitrary context addressing. I tend to see this as more of a feature than a bug, but it does lead to some discomfort around key masking. @janl I've created a new issue for discussing masked key resolution. See #11. |
Issue #11 is primarily focussed on discussing mechanisms for accessing masked data. The problems described here are special cases of anchored lookups (which we have, implemented using dotted names); specifically that there is no reliable way of handling anchored lookups across iteration boundaries. The issue you raised is probably the most common instance of the problem, where you want a name (or convention) you can use to anchor the lookup to the top of stack. The simple fix is to provide a construct that anchors lookups to the top of stack.
A more general fix is to give the top of stack an anchorable name.
An even more general (and somewhat disjoint) fix is to provide a name for the current iteration element.
The advantage to this last case is that it permits an anchor for any section's current iteration (with a unique name). It's also arguably the hardest to implement. tl;dr: There's still an issue here; let's not close this down just yet. |
/cc @cjerdonek (Is there a better way to subscribe to an issue?) |
There's a link to enable notifications just below the comment form :) |
Hello, Just wanted to reping this issue. I had to implement work around for it today. I support(ed) the way leth proposed (even before seeing this issue). Here's the link to the same issue i opened with GRMustache. |
Given the following context:
The following:
Will output something like:
It might be nice if you could syntactically limit the context to the current iteration
To get:
The use case I have is printing out html sytlesheet include fragments: the optional title attribute is missing, and it's finding the page title attribute up the context stack.
The text was updated successfully, but these errors were encountered: