Exemplo n.º 1
0
def nginxssi(parser, token):
    tokens = token.split_contents()
    # automatically generate key based on template code
    template_string = render_raw_template(parser, token, 'endnginxssi')
    cache_key = generate_ssi_cache_key(template_string)
    if cache_key not in cache:
        cache.set(cache_key, template_string)
    return NginxSSINode(cache_key)
Exemplo n.º 2
0
 def test_ssi_template_rendering(self):
     ssi_fragment = '<b> okidoki </b> {%now "jS F Y H:i"%} Hello {{foo}}'
     template_string = """
         {% load nginxssi_tags %}
         {% nginxssi %}""" + ssi_fragment + """{% endnginxssi %}
     """
     template = Template(template_string)
     context = Context({'foo': 'bar'})
     template_response = template.render(context)
     cache_key = generate_ssi_cache_key(ssi_fragment)
     self.assertTrue('<!--# include virtual="/nginxssi/%s/" -->' % cache_key \
                         in template_response)
     
     client = Client()
     response = client.get(reverse('nginxssi',args=(cache_key,)))
     template = Template(ssi_fragment)
     self.assertEquals(response.content.strip(), template.render(context).strip())