本文整理匯總了Python中pystache.renderer.Renderer.render_path方法的典型用法代碼示例。如果您正苦於以下問題:Python Renderer.render_path方法的具體用法?Python Renderer.render_path怎麽用?Python Renderer.render_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pystache.renderer.Renderer
的用法示例。
在下文中一共展示了Renderer.render_path方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Renderer
# 需要導入模塊: from pystache.renderer import Renderer [as 別名]
# 或者: from pystache.renderer.Renderer import render_path [as 別名]
# test_obj = {
# 'title': 'A fucking title'
# }
#
# title_partial = {'page-title': 'Some cinder crap | {{title}}'}
# renderer = Renderer(partials=title_partial)
# renderer.search_dirs.append(TEMPLATE_DIR)
# path = os.path.join(TEMPLATE_DIR, "master-template.mustache")
# actual = renderer.render_path(path, test_obj)
# print actual
# step 1: render content in template
content_renderer = Renderer()
path = os.path.join(CLASS_TEMPLATE_DIR, "main-content-template.mustache")
content_renderer.search_dirs.append(TEMPLATE_DIR)
rendered_content = content_renderer.render_path(path, class_obj)
# step 2: place rendered content into main template
# - should have the following custom partials:
# - page title (define in object for page templates)
# - page content (rendered page content)
# - any other common partials that may lie outside the basic content area
test_obj = {"title": class_obj["name"]}
loader = Loader()
# template = loader.read("title")
title_partial = loader.load_name(os.path.join(CLASS_TEMPLATE_DIR, "title"))
partials = {"page-title": title_partial, "main-content": rendered_content}
renderer = Renderer(partials=partials)