from django.utils.safestring import mark_safe
from django_jinja import library
from jinja2 import contextfunction
import jinja2
def register_tag(silhouette_class):
# Django_jinja has it's own tag registration
#register.simple_tag(tag, True, tag_name)
library.global_function(tag_name,tag)
tag.contextfunction = True
def __enter__(self):
# Context is jinja2 context object, doesn't support update
#self.context.update(scope)
self.context.vars.update(scope)
def __exit__(self, *args, **kwargs):
# Jinja context object doesn't support pop
#self.context.pop()
return self.context
def render(self, context):
#return render_to_string(self.template,context)
result = self.template.render(context)
return mark_safe(result)
silhouette_filters.py
Basically all of those will need to be registered with django_jinja too. Should just be able to do a decorator similar to what you have done in silhouette_tags.py
I then had to create my own template as the template markup is a bit different but essentially it works. Would be great if jinja could be optionally supported by django-silhouette and even better if you provided a "jinja" template for it.
Hi Thierry,
Attempting to use silhouette with Jinja (https://niwibe.github.io/django-jinja/) and had to do a couple of hacks :P
silhouette_tags.py
silhouette_filters.py
Basically all of those will need to be registered with django_jinja too. Should just be able to do a decorator similar to what you have done in silhouette_tags.py
I then had to create my own template as the template markup is a bit different but essentially it works. Would be great if jinja could be optionally supported by django-silhouette and even better if you provided a "jinja" template for it.
yes, asking a lot, cheers, TiM~