Impossible to override context in for a child template
In GitLab by @m1kola on Dec 14, 2017, 11:38
If you have a some_page.html&some_page.yaml and include_me.html&include_me.html and some_page.html includes include_me.html.
some_page.yaml with something like:
context:
page:
pk: 1
title: "my title"
and include_me.yaml with something like:
context:
page:
title: "Title from include"
Title from include will appear on both patterns. It's impossible to override single key in some_page.html
cc @bcdickinson
In GitLab by @m1kola on Dec 14, 2017, 11:42
Hm. Actually, probably my description is incorrect... I'll double check later
This feels like something that should at least documented if indeed an issue.
To do this properly, we could take a leaf out of docker-compose's book and steal its MergeDict stuff: https://github.com/docker/compose/blob/df05472bcc6f1596e519a1e02f01cebd4e160011/compose/config/config.py#L984
Mentioned in the docs as of #131.
Closed in favour of #138.
I'm going to repoen this, as it's not a strict duplicate. This is concerning the hiding of context values set in outer contexts by those set in included/extended template contexts, whereas #138 is about controlling the output of tags that are not explicitly called by included/extended template in inner contexts (I know, this makes my brain hurt too).
I've come across https://github.com/clarketm/mergedeep which might be useful here.