mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Added documentation about variable scoping in "partials".
This commit is contained in:
parent
8f8120ba14
commit
bc48b4606a
1 changed files with 18 additions and 2 deletions
|
@ -106,5 +106,21 @@ To reference a partial template stored in a subfolder, e.g. `/layout/partials/po
|
||||||
|
|
||||||
Note that the subdirectories you create under /layout/partials can be named whatever you like.
|
Note that the subdirectories you create under /layout/partials can be named whatever you like.
|
||||||
|
|
||||||
**For more examples of referencing these templates, see [single content
|
For more examples of referencing these templates, see
|
||||||
templates](/templates/content/), [list templates](/templates/list/) and [homepage templates](/templates/homepage/).**
|
[single content templates](/templates/content/),
|
||||||
|
[list templates](/templates/list/) and
|
||||||
|
[homepage templates](/templates/homepage/).
|
||||||
|
|
||||||
|
|
||||||
|
Variable scoping
|
||||||
|
----------------
|
||||||
|
|
||||||
|
As you might have noticed, `partial` calls receive two paramters.
|
||||||
|
|
||||||
|
1. The first is the name of the partial and determines the file
|
||||||
|
location to be read.
|
||||||
|
2. The second is the variables to be passed down to the partial.
|
||||||
|
|
||||||
|
This means the partial _only_ be able to access those variables. It is
|
||||||
|
isolated and has no access to the outer scope. From within the
|
||||||
|
partial, `$.Var` is equivalent to `.Var`
|
||||||
|
|
Loading…
Reference in a new issue