Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Mustache v2.0 commentary #178

Closed
karlmikko opened this Issue Mar 2, 2012 · 2 comments

Comments

Projects
None yet
3 participants

Hi Jan,

Context and "." notation are connected. see examples below. code samples taken from your blog http://writing.jan.io/mustache-2.0.html

var view = {
foo: {
bar: {
baz: 1
},
qux: 2
}
};

Context example that handlebars used
{{#foo}}
{{#bar}}
{{baz}}
{{../qux}} # ah-ha!
{{/bar}}
{{/foo}}

Current non dot notaion
{{#foo}}
{{bar}}
{{/foo}}

dot notation
{{foo.bar}}

This is how i see that the dot notation should fix context!
{{#foo}}
{{#bar}}
{{baz}}
{{foo.qux}} # use dot notation!
{{/bar}}
{{/foo}}

This approach would also mean that deep nested arrays and objects would be clear when reading the template not ../../../../qux which i agree with you is ugly and confusing.

which would mean this is also valid
{{#foo}}
{{foo.bar}}
{{/foo}}

You have a very good point about reading ../../../../qux more simplicity and unification is better, that's what mustache is all about.

What if you have:

{
  foo: {
    foo: {
      foo: 'bar'
    }
  }
}

This becomes un-interpretable, for example what do:

{{foo}}, {{foo.foo.foo}}, and {{foo.foo}} mean?

You could write this as a bad edge case, but I would disagree.

Collaborator

dasilvacontin commented Dec 20, 2014

I'll close this issue due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment