本文整理汇总了Python中pelican.contents.Page.save_as方法的典型用法代码示例。如果您正苦于以下问题:Python Page.save_as方法的具体用法?Python Page.save_as怎么用?Python Page.save_as使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pelican.contents.Page
的用法示例。
在下文中一共展示了Page.save_as方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_as
# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import save_as [as 别名]
def test_save_as(self):
# if a lang is not the default lang, save_as should be set accordingly
page = Page('content', {'title': 'foobar', 'lang': 'fr'}) #default lang is en
self.assertEqual(page.save_as, "foobar-fr.html")
# otherwise, if a title is defined, save_as should be set
page = Page('content', {'title': 'foobar'})
page.save_as = 'foobar.html'
示例2: test_save_as
# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import save_as [as 别名]
def test_save_as(self):
# if a lang is not the default lang, save_as should be set accordingly
page = Page("content", {"title": "foobar", "lang": "fr"}) # default lang is en
self.assertEqual(page.save_as, "foobar-fr.html")
# otherwise, if a title is defined, save_as should be set
page = Page("content", {"title": "foobar"})
page.save_as = "foobar.html"
# if no title is given, there is no save_as
page = Page("content")
self.assertFalse(hasattr(page, "save_as"))
示例3: test_save_as
# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import save_as [as 别名]
def test_save_as(self):
"""If a lang is not the default lang, save_as should be set
accordingly.
"""
# if a title is defined, save_as should be set
page = Page(**self.page_kwargs)
page.save_as = 'foo-bar.html'
# if a language is defined, save_as should include it accordingly
self.page_kwargs['metadata'].update({'lang': 'fr', })
page = Page(**self.page_kwargs)
self.assertEqual(page.save_as, "foo-bar-fr.html")
示例4: generate_context
# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import save_as [as 别名]
def generate_context(self):
all_pages = []
for f in self.get_files(os.sep.join((self.path, 'pages'))):
content, metadata = read_file(f)
page = Page(content, metadata, settings=self.settings,
filename=f)
if not is_valid_content(page, f):
continue
if self.settings.get('CLEAN_URLS_NO_PROXY'):
# cleaning page url
page.save_as = os.path.join(page.slug, 'index.html')
page.url = os.path.dirname(page.save_as) + '/'
all_pages.append(page)
self.pages, self.translations = process_translations(all_pages)
self._update_context(('pages', ))
self.context['PAGES'] = self.pages