当前位置: 首页>>代码示例>>Python>>正文


Python Page.save_as方法代码示例

本文整理汇总了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'
开发者ID:sgenoud,项目名称:pelican,代码行数:10,代码来源:test_contents.py

示例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"))
开发者ID:n1k0,项目名称:pelican,代码行数:14,代码来源:test_contents.py

示例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")
开发者ID:hdonnay,项目名称:pelican,代码行数:15,代码来源:test_contents.py

示例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
开发者ID:mviera,项目名称:pelican,代码行数:22,代码来源:generators.py


注:本文中的pelican.contents.Page.save_as方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。