5monkeys/django-viewlet — pull request #20 by heyman (2013-05-24 17:10:12+00:00)
Title: Load jinja Environment lazily and cache it

This avoids a circular dependency when a project's jinja Environment is declared at the module level and depends on django settings (since django-viewlet imports the Environment at project startup).

I have a project where I don't use either jingo or coffin, but instead I've rolled my own jinja2 integration. In this project I declare my jinja Environment at the module level like this:

```python
env = Environment(
loader=FileSystemLoader(settings.JINJA_TEMPLATE_DIRS),
extensions=settings.JINJA_EXTENSIONS,
autoescape=True,
)
```

This doesn't work with the current version of viewlet, but this pull request fixes it.

I made these changes pretty fast without too much insight in the code base, so please look them through if you're going to merge them :). All tests passes at least.