Example #1
0
 def _render_html(self, request, t, **kwargs):
     if type(t) == str:
         t = Template(t)
     else:
         t = Template(t.read())
     c = RequestContext(request, kwargs)
     return t.render(c)
Example #2
0
def Deserializer(stream_or_string, **options):
    """
    Deserialize a stream or string of Django template data.
    """
    from django.template import Context, Template
    filepath = os.path.splitext(options.get('filepath'))[0]
    # adjust filepath
    options['filepath'] = filepath
    stream_or_string = Template(stream_or_string.read()).render(Context({}))
    return serializers.deserialize(filepath.split('.')[-1], stream_or_string, **options)