From 72f445b1e9b5e6000bb3b10a42683ab6779d8e9e Mon Sep 17 00:00:00 2001 From: Kenton Varda Date: Tue, 14 Jul 2015 21:16:21 -0700 Subject: [PATCH 1/2] Clarify docs about template inclusions + helpers I'm not sure that this is the best way to document this, but I spent a while confused by this, so it would be nice to mention in the docs somewhere. --- packages/spacebars/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/spacebars/README.md b/packages/spacebars/README.md index a30214eb6c..cc47f93ac5 100644 --- a/packages/spacebars/README.md +++ b/packages/spacebars/README.md @@ -254,6 +254,14 @@ Instead of simply naming a template, an inclusion tag can also specify a path that evalutes to a template object, or to a function that returns a template object. +Note that the above two points interact in a way that can be surprising! +If `foo` is a template helper function that returns another template, then +`{{>foo bar}}` will _first_ push `bar` onto the data context stack _then_ call +`foo()`, due to the way this line is expanded as shown above. You will need to +use `Template.parentObject(1)` to access the original context. This differs +from regular helper calls like `{{foo bar}}`, in which `bar` is passed as a +parameter rather than pushed onto the data context stack. + ### Function Returning a Template If an inclusion tag resolves to a function, the function must return a template From cc80a5fc189795407172aac1102c0646ce80be67 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Tue, 21 Jul 2015 19:00:44 -0700 Subject: [PATCH 2/2] Fix typo --- packages/spacebars/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/spacebars/README.md b/packages/spacebars/README.md index cc47f93ac5..51ddfdb41c 100644 --- a/packages/spacebars/README.md +++ b/packages/spacebars/README.md @@ -258,7 +258,7 @@ Note that the above two points interact in a way that can be surprising! If `foo` is a template helper function that returns another template, then `{{>foo bar}}` will _first_ push `bar` onto the data context stack _then_ call `foo()`, due to the way this line is expanded as shown above. You will need to -use `Template.parentObject(1)` to access the original context. This differs +use `Template.parentData(1)` to access the original context. This differs from regular helper calls like `{{foo bar}}`, in which `bar` is passed as a parameter rather than pushed onto the data context stack.