當前位置: 首頁>>代碼示例>>Python>>正文


Python runtime.Context方法代碼示例

本文整理匯總了Python中jinja2.runtime.Context方法的典型用法代碼示例。如果您正苦於以下問題:Python runtime.Context方法的具體用法?Python runtime.Context怎麽用?Python runtime.Context使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jinja2.runtime的用法示例。


在下文中一共展示了runtime.Context方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: new_context

# 需要導入模塊: from jinja2 import runtime [as 別名]
# 或者: from jinja2.runtime import Context [as 別名]
def new_context(self, vars=None, shared=False, locals=None):
        """Create a new :class:`Context` for this template.  The vars
        provided will be passed to the template.  Per default the globals
        are added to the context.  If shared is set to `True` the data
        is passed as it to the context without adding the globals.

        `locals` can be a dict of local variables for internal usage.
        """
        return new_context(self.environment, self.name, self.blocks,
                           vars, shared, self.globals, locals) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:12,代碼來源:environment.py

示例2: get_id

# 需要導入模塊: from jinja2 import runtime [as 別名]
# 或者: from jinja2.runtime import Context [as 別名]
def get_id(context: Context, prefix: str) -> str:
    """
    A jinja2 context filter for creating reusable unique identifiers within a
    cauldron display. The uid is designed to be unique within each step within
    a project, as well as unique each time that step is rendered. A UID is
    made up of three pieces::

        cdi-[PREFIX]-[RENDER_HASH]

    The "cdi" is a universal prefix that prevents any possible collision with
    non-cauldron IDs in the page. The [PREFIX] is supplied by the prefix
    argument to separate different IDs inside the same render step. The
    [RENDER_HASH] is a unique character string that is created uniquely each
    time a render step completes.

    :param context:
        Jinja2 context in which this filter is being applied
    :param prefix:
        Prefix string that indicates which uid is being created within a step
    :return:
        A uniquely identifying string.
    """
    return 'cdi-{}-{}'.format(
        prefix,
        context['cauldron_template_uid']
    ) 
開發者ID:sernst,項目名稱:cauldron,代碼行數:28,代碼來源:templating.py

示例3: get_latex

# 需要導入模塊: from jinja2 import runtime [as 別名]
# 或者: from jinja2.runtime import Context [as 別名]
def get_latex(content:Context, prefix: str) -> str:
    """..."""
    return '\n\n{}\n\n'.format(render_template(
        'katex.html',
        source=utils.format_latex(prefix)
    )) 
開發者ID:sernst,項目名稱:cauldron,代碼行數:8,代碼來源:templating.py


注:本文中的jinja2.runtime.Context方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。