本文整理汇总了Python中microsite_configuration.middleware.MicrositeConfiguration.get_microsite_template_path方法的典型用法代码示例。如果您正苦于以下问题:Python MicrositeConfiguration.get_microsite_template_path方法的具体用法?Python MicrositeConfiguration.get_microsite_template_path怎么用?Python MicrositeConfiguration.get_microsite_template_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类microsite_configuration.middleware.MicrositeConfiguration
的用法示例。
在下文中一共展示了MicrositeConfiguration.get_microsite_template_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_to_string
# 需要导入模块: from microsite_configuration.middleware import MicrositeConfiguration [as 别名]
# 或者: from microsite_configuration.middleware.MicrositeConfiguration import get_microsite_template_path [as 别名]
def render_to_string(template_name, dictionary, context=None, namespace='main'):
# see if there is an override template defined in the microsite
template_name = MicrositeConfiguration.get_microsite_template_path(template_name)
context_instance = Context(dictionary)
# add dictionary to context_instance
context_instance.update(dictionary or {})
# collapse context_instance to a single dictionary for mako
context_dictionary = {}
context_instance['settings'] = settings
context_instance['EDX_ROOT_URL'] = settings.EDX_ROOT_URL
context_instance['marketing_link'] = marketing_link
# In various testing contexts, there might not be a current request context.
if edxmako.middleware.requestcontext is not None:
for d in edxmako.middleware.requestcontext:
context_dictionary.update(d)
for d in context_instance:
context_dictionary.update(d)
if context:
context_dictionary.update(context)
# fetch and render template
template = edxmako.lookup[namespace].get_template(template_name)
return template.render_unicode(**context_dictionary)
示例2: render_to_response
# 需要导入模块: from microsite_configuration.middleware import MicrositeConfiguration [as 别名]
# 或者: from microsite_configuration.middleware.MicrositeConfiguration import get_microsite_template_path [as 别名]
def render_to_response(template_name, dictionary=None, context_instance=None, namespace='main', **kwargs):
"""
Returns a HttpResponse whose content is filled with the result of calling
lookup.get_template(args[0]).render with the passed arguments.
"""
# see if there is an override template defined in the microsite
template_name = MicrositeConfiguration.get_microsite_template_path(template_name)
dictionary = dictionary or {}
return HttpResponse(render_to_string(template_name, dictionary, context_instance, namespace), **kwargs)