Index: core/defaulttags.py =================================================================== --- core/defaulttags.py (revision 854) +++ core/defaulttags.py (working copy) @@ -1,7 +1,9 @@ "Default tags used by the template system, available to all templates." +import os import sys import template +import template_file class CommentNode(template.Node): def render(self, context): @@ -210,14 +212,20 @@ self.filepath, self.parsed = filepath, parsed def render(self, context): - if not include_is_allowed(self.filepath): - return '' # Fail silently for invalid includes. - try: - fp = open(self.filepath, 'r') - output = fp.read() - fp.close() - except IOError: - output = '' + if not os.path.isabs(self.filepath): + try: + output = template_file.load_template_source(self.filepath) + except template.TemplateDoesNotExist: + return '' # Fail silently for non-existant templates + else: + if not include_is_allowed(self.filepath): + return '' # Fail silently for invalid includes. + try: + fp = open(self.filepath, 'r') + output = fp.read() + fp.close() + except IOError: + output = '' if self.parsed: try: t = template.Template(output) @@ -586,11 +594,17 @@ Output the contents of a given file into the page. Like a simple "include" tag, the ``ssi`` tag includes the contents - of another file -- which must be specified using an absolute page -- - in the current page:: + of another file in the current page. The file must be specified + as either an absolute path (in which case the path must be in the + ALLOWED_INCLUDE_ROOTS setting in settings/main.py):: {% ssi /home/html/ljworld.com/includes/right_generic.html %} + ... or as a relative path to a template file as per a call to + template_loader.get_template():: + + {% ssi news/right_generic %} + If the optional "parsed" parameter is given, the contents of the included file are evaluated as template code, with the current context::