[plug] Jinja/LaTeX child templates (this time on github instead of attachment)

Chris Caston chris at caston.id.au
Tue Jan 28 20:09:41 AWST 2020


Sorry for replying to my own post. I noticed something curious. When I
uncommented: template2 = latex_jinja_env.get_template('test2.template') and
run the python3 script again I now get
jinja2.exceptions.TemplateSyntaxError: Unexpected end of template. Jinja
was looking for the following tags: 'endblock'. The innermost block that
needs to be closed is 'block'.

I think we might be very close!

On Tue, Jan 28, 2020 at 7:47 PM Chris Caston <chris at caston.id.au> wrote:

> Hi Kirk,
>
> Thank you for your excellent help.
>
> I just realised I have been sending directly to you rather than posting to
> the list.
>
> I have updated the file: test2.template:
>
> \BLOCK{ extends "jinja-test.template" }
>
> \BLOCK{block content}
> This provides you some additional text from the child block.
>
>
> \BLOCK{ block content }
>  My string: \VAR{my_string}
>
>
>
> Loop through the list:
> \begin{itemize}
> \item
> \BLOCK{ for n in my_list }
> \VAR{n}
> \BLOCK{ endfor }
>
> \end{itemize}
>
>
> \BLOCK{ endblock }
>
> in jinja-test.template it now has:
> \section{\VAR{section8}}
>
> \BLOCK{block content}\BLOCK{endblock}
>
> \end{document}
>
> I have updated the files at: https://github.com/warmheartcoin/jinjalatex
>
>
> It still doesn't render the child template. Perhaps it can't find it?
>
> Do I need load the template perhaps something like this? (from
> https://jinja.palletsprojects.com/en/2.10.x/api/)
>
>
> from jinja2 import Environment, PackageLoader, select_autoescapeenv = Environment(
>     loader=PackageLoader('yourapplication', 'templates'),
>     autoescape=select_autoescape(['html', 'xml']))
>
>
> On Tue, Jan 28, 2020 at 3:08 PM Chris Caston <chris at caston.id.au> wrote:
>
>> Thanks Kirk,
>>
>> I will have another try at getting it to work based on your feedback
>> soon. I also found the following on github which as been very helpful with
>> a few examples. https://github.com/pappasam/latexbuild
>> I was working on those examples last night but using his code copied into
>> in mine and I felt I had almost got it to work but eventually had to give
>> in to sleep.
>>
>> I have also decided that I will open source the project that I am working
>> on. It's the right thing to do (especially as everything I am using to
>> build it is open source) and I hope to reveal more about the project soon.
>>
>> best regards,
>>
>> Christopher Caston
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20200128/7818ce0f/attachment.html>


More information about the plug mailing list