Pelican Plugin - How to add context variables?

I am making a pelican plugin and I'm having trouble adding variables to the templates.

For example in my plugin's 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 show in the <h1>.

I have been looking at https://github.com/getpelican/pelican/blob/807b3bced38bff7b83a2efa2ce8cda9d644ebad3/pelican/generators.py trying to see how I can add this as an environment variable to no avail. Any help is much appreciated.

Answers


What I needed was

generator.context['foo'] = 'bar'

Need Your Help

Scrapy grab div with multiple classes?

python html xpath web-scraping scrapy

I am trying to grab div's with the class: 'product'. The problem is, some of the div's with class 'product' also have the class 'product-small'. So when I use xpath('//div[@class='product']'), it o...

Kiwi unit tests never failing in Xcode

ios objective-c xcode unit-testing kiwi

For some reason my tests are passing every time. Even when I add

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.