Pelican Plugin - How to add context variables?

I am making a Pelican plugin and I am having problems adding variables to the templates.

For example, in my plugin code:

def baz(generator): generator.foo = 'bar' def register(): signals.generator_init.connect(baz) 

And in my templates I have:

 <h1>lorem - {{foo}}</h1> 

And I would expect lorem - bar to display in <h1> .

I watched https://github.com/getpelican/pelican/blob/807b3bced38bff7b83a2efa2ce8cda9d644ebad3/pelican/generators.py trying to figure out how I can add this as an environment variable to no avail. Any help is much appreciated.

+5
source share
1 answer

I had to

 generator.context['foo'] = 'bar' 
+4
source

All Articles