2008-07-29 13:54:20 +00:00
|
|
|
from os.path import join
|
2008-06-26 14:36:58 +00:00
|
|
|
|
2008-07-29 13:54:20 +00:00
|
|
|
from django.template import TemplateDoesNotExist
|
|
|
|
from django.template.context import RequestContext
|
|
|
|
from django.shortcuts import render_to_response
|
|
|
|
from django.http import Http404
|
2008-06-26 14:36:58 +00:00
|
|
|
|
|
|
|
|
2008-07-29 13:54:20 +00:00
|
|
|
ARTICLES_TEMPLATES_DIR = "articles"
|
2008-06-26 14:36:58 +00:00
|
|
|
|
2008-07-25 16:59:27 +00:00
|
|
|
|
2008-07-29 13:54:20 +00:00
|
|
|
def render_template(request, path):
|
|
|
|
if not path.endswith(".html"):
|
|
|
|
path = path + ".html"
|
|
|
|
path = join(ARTICLES_TEMPLATES_DIR, path)
|
|
|
|
|
|
|
|
try:
|
|
|
|
c = RequestContext(request)
|
|
|
|
return render_to_response(path, context_instance=c)
|
|
|
|
except TemplateDoesNotExist, e:
|
|
|
|
raise Http404("Article does not exists")
|