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


Python Template.render_partial方法代码示例

本文整理汇总了Python中breve.Template.render_partial方法的典型用法代码示例。如果您正苦于以下问题:Python Template.render_partial方法的具体用法?Python Template.render_partial怎么用?Python Template.render_partial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在breve.Template的用法示例。


在下文中一共展示了Template.render_partial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: render

# 需要导入模块: from breve import Template [as 别名]
# 或者: from breve.Template import render_partial [as 别名]
    def render ( self, info, format = "html", fragment = False, template = None ):
        """
        info == dict of variables to stick into the template namespace
        format == output format if applicable
        fragment == special rules about rendering part of a page
        template == dotted.path.to.template (without .ext)
        """

        vars = info

        # check to see if we were passed a function get extra vars
        if callable ( self.get_extra_vars ):
            vars.update ( self.get_extra_vars ( ) )
            
        self.breve_opts.update ( self.get_config ( vars ) )
        template_path, template_filename, args = self.load_template ( template )
        # self.breve_opts.update ( args )

        template_root = self.breve_opts [ 'root' ]
        format = args.get ( 'format', format )

        if template_root and template_path.startswith ( template_root ):
            # this feels mildly brittle
            template_path = template_path [ len ( template_root ) + 1: ]

        if format not in self.tag_defs:
            # this seems weak (concerns about path). Should perhaps
            # find a better way, but getting only a string for format
            # makes it difficult to do too much
            self.tag_defs [ format ] = __import__ ( format, { }, { } )

        self.breve_opts [ 'doctype' ] = self.breve_opts.get ( 'doctype', self.tag_defs [ format ].doctype )
        template_obj = Template ( tags = self.tag_defs [ format ].tags,
                                  xmlns = self.tag_defs [ format ].xmlns,
                                  **self.breve_opts )

        if fragment:
            return template_obj.render_partial ( os.path.join ( template_path, template_filename ),
                                                 vars = vars, **self.breve_opts )
        
        return template_obj.render ( os.path.join ( template_path, template_filename ),
                                     vars = vars, **self.breve_opts )
开发者ID:BenoitZugmeyer,项目名称:breve,代码行数:44,代码来源:buffet.py


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