<div dir="ltr">Hi Chris,<div><br></div><div>I'll preface this by a "I'm not a jinja2 expert" (I've mostly used it for ansible templates) - but having a second pair of eyes on it helps!</div><div><br></div><div>The problem is two fold:</div><div>1. In your Environment creation you've changed the markers for the start (and end blocks) from {% to \BLOCK{ - but then proceeded to use the old markers in some places - so in your child template you'll need to have:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>\BLOCK{ extends "jinja-test.template" }</div><div><br></div><div>\BLOCK{ block content }</div><div> My string: \VAR{my_string}</div><div><br></div><div><br></div><div> Value from the list: \VAR{my_list[3]}</div><div><br></div><div> Loop through the list:</div><div>\begin{itemize}</div><div>\item</div><div>\BLOCK{ for n in my_list }</div><div>\VAR{n}</div><div>\BLOCK{ endfor }</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>\end{itemize}</div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><br></div><div>\BLOCK{ endblock }</div></blockquote><div><br></div><div>Note the for loop also seems to be missing the endfor so I've also adjusted that.</div><div><br></div><div>Likewise there are still some usages of the {% block declarations in the jinja-test.templates file too.</div><div><br></div><div>2. I'm guessing you'd figure this out given the commented out lines in the test case - but you need to load and render the 'child' template (so the test2.template) - it then loads the base or parent template and replaces the appropriate parts in there. </div><div><br></div><div>Thanks,</div><div><br></div><div>Kirk</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 27 Jan 2020 at 15:49, Chris Caston <<a href="mailto:chris@caston.id.au">chris@caston.id.au</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I have been trying to figure out how to use child templates
(amongst other things you will see in the git repository hosted python and LaTeX
template code) in Jinja when working with LaTeX. This has been tricky as
most of the pages I can find are specific to HTML.</div><div><br></div><div>I am trying to render the child template (test2.template) in jinja-test.template where I have written:</div><div><br></div><div>\section{\VAR{section8}}<br> {% block content %}{% endblock %}</div><div><br></div><div>I have probably missed something very simple but looking at so much code from so many <br></div><div>places is getting me confused.</div><div><br></div><div>Here is my code so far and the links to resources I am been trying to learn from:</div><div><br></div><div><a href="https://jinja.palletsprojects.com/en/2.10.x/templates/#base-template" target="_blank">https://jinja.palletsprojects.com/en/2.10.x/templates/#base-template</a></div><div><a href="https://realpython.com/primer-on-jinja-templating/" target="_blank">https://realpython.com/primer-on-jinja-templating/</a></div><div><br></div><div><a href="http://akuederle.com/Automatization-with-Latex-and-Python-2" target="_blank">http://akuederle.com/Automatization-with-Latex-and-Python-2</a></div><div><a href="http://eosrei.net/articles/2015/11/latex-templates-python-and-jinja2-generate-pdfs" target="_blank">http://eosrei.net/articles/2015/11/latex-templates-python-and-jinja2-generate-pdfs</a></div><div><br></div><div>Here is the code on github. <a href="https://github.com/warmheartcoin/jinjalatex.git" target="_blank">https://github.com/warmheartcoin/jinjalatex.git</a></div><div>Thank you in advance for your help.</div><div><br></div><div>best regards,</div><div><br></div><div>Chris Caston</div></div>
_______________________________________________<br>
PLUG discussion list: <a href="mailto:plug@plug.org.au" target="_blank">plug@plug.org.au</a><br>
<a href="http://lists.plug.org.au/mailman/listinfo/plug" rel="noreferrer" target="_blank">http://lists.plug.org.au/mailman/listinfo/plug</a><br>
Committee e-mail: <a href="mailto:committee@plug.org.au" target="_blank">committee@plug.org.au</a><br>
PLUG Membership: <a href="http://www.plug.org.au/membership" rel="noreferrer" target="_blank">http://www.plug.org.au/membership</a></blockquote></div>