janl/mustache.js — Issue #178: Mustache v2.0 commentary
Author: KingKarl85
Created: 2012-03-02 01:41:47+00:00
State: open

Hi Jan,

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

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}}