Pass var from page to partial to another partial (!)

Howdy there!

My setup:

/layouts/index.html  
/layouts/partials/page/snippet/featured.html
/layouts/partials/promotions/cool.html
Data:
------
$hello := "wow, hello!"
index.html
------------------
{{ partial "page/snippet/featured.html" (dict "hello" $hello) . }}
{{ .hello }} (displays "wow, hello!")
featured.html
----------------
{{ partial "partials/promotions/cool.html" (dict "helllo" $hello) . }}   
{{ .hello }} (displays "wow, hello!")
cool.html
----------------
{{ .hello }}   (doesn't shows anything)

See what the problem is?

Now, I have that partial within a partial because I call that “cool.html” partial from other parts of the site as well, and the “featured.html” is also a partial, which gets called from home.

Somehow passing a variable works oka the first time, but from the partial TO another partial, that’s when it doesn’t works.

And I’ve tried to pass variables I’ve created within the partial, even Scratch doesn’t works.

edit
Actually, no page or site variable work from within a partial called from another partial. Scratch doesn’t works either.

When passing the data to the cool partial, you have a typo in the key: you put helllo instead of hello

2 Likes