diff --git a/common/lib/mitxmako/mitxmako/template.py b/common/lib/mitxmako/mitxmako/template.py index e8fc24a4be..fa6b1293f8 100644 --- a/common/lib/mitxmako/mitxmako/template.py +++ b/common/lib/mitxmako/mitxmako/template.py @@ -20,7 +20,7 @@ from mitxmako import middleware django_variables = ['lookup', 'output_encoding', 'module_directory', 'encoding_errors'] - +# TODO: We should make this a Django Template subclass that simply has the MakoTemplate inside of it? (Intead of inheriting from MakoTemplate) class Template(MakoTemplate): """ This bridges the gap between a Mako template and a djano template. It can diff --git a/common/lib/mitxmako/mitxmako/templatetag_helpers.py b/common/lib/mitxmako/mitxmako/templatetag_helpers.py new file mode 100644 index 0000000000..0c66cea090 --- /dev/null +++ b/common/lib/mitxmako/mitxmako/templatetag_helpers.py @@ -0,0 +1,23 @@ +from django.template.base import Template, Context +from django.template.loader import get_template, select_template + + +def render_inclusion(func, file_name, *args, **kwargs): + _dict = func(*args, **kwargs) + if isinstance(file_name, Template): + t = file_name + elif not isinstance(file_name, basestring) and is_iterable(file_name): + t = select_template(file_name) + else: + t = get_template(file_name) + + nodelist = t.nodelist + + new_context = Context(_dict) + # **{ + # 'autoescape': context.autoescape, + # 'current_app': context.current_app, + # 'use_l10n': context.use_l10n, + # 'use_tz': context.use_tz, + # }) + return nodelist.render(new_context) diff --git a/lms/templates/wiki/article.html b/lms/templates/wiki/article.html index 45b3071141..bedeb368d0 100644 --- a/lms/templates/wiki/article.html +++ b/lms/templates/wiki/article.html @@ -1,48 +1,51 @@ ## mako -<%inherit file="../main.html"/> -<%namespace name='static' file='../static_content.html'/> +<%inherit file="mako_base.html"/> -<%block name="bodyextra"> +<%! + from wiki.templatetags.wiki_tags import wiki_render + from mitxmako.templatetag_helpers import render_inclusion +%> -This is a mako template with inheritance! +<%namespace name="article_menu" file="includes/article_menu.html"/> + + +<%block name="title">