pug - Jade templates django - Use captured url value in urls.py -
i have "static" javascript templates want serve django application. put them in static folder , that's it. problem here templates aren't static, jade(pyjade) templates need pre-compiled.
plan having templates inside sub-directory of app's templates dir, lets call jstemplates, , serve them urls.py
file this:
... url(r'^jstemplates/(?p<template>.*)', templateview.as_view(template_name=<captured_name>)), ...
but how can captured template name?
thinking better, suppose captured attribute won't available until view's instantiation made sub-class of templateview called jstemplateview.
class jstemplateview(templateview): def get_template_names(self): return "jstemplates/%s.jade" % self.kwargs['template']
and added corresponding line in urls.py url(r'^jstemplates/(?p<template>.*)', jstemplateview.as_view()
Comments
Post a Comment