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


Python Token.output_as_string方法代码示例

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


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

示例1: compile_javascript_string

# 需要导入模块: from template_preprocessor.core.lexer import Token [as 别名]
# 或者: from template_preprocessor.core.lexer.Token import output_as_string [as 别名]
def compile_javascript_string(js_string, context, path=''):
    """
    Compile JS code (can be used for external javascript files)
    """
    # First, create a tree to begin with
    tree = Token(name='root', line=1, column=1, path=path)
    tree.children = [ js_string ]

    # Tokenize
    tokenize(tree, __JS_STATES, Token)

    # Compile
    _compile(tree, context)

    # Output
    return tree.output_as_string()
开发者ID:globocom,项目名称:django-template-preprocessor,代码行数:18,代码来源:js_processor.py

示例2: compile_html_string

# 需要导入模块: from template_preprocessor.core.lexer import Token [as 别名]
# 或者: from template_preprocessor.core.lexer.Token import output_as_string [as 别名]
def compile_html_string(html_string, path=''):
    """
    Compile a html string
    """
    # First, create a tree to begin with
    tree = Token(name='root', line=1, column=1, path=path)
    tree.children = [ html_string ]

    # Tokenize
    tokenize(tree, __HTML_STATES, Token)

    from template_preprocessor.core.context import Context
    context = Context(path)
    _process_html_tree(tree, context)

    # Output
    return tree.output_as_string()
开发者ID:sentido,项目名称:django-template-preprocessor,代码行数:19,代码来源:html_processor.py

示例3: compile_html_string

# 需要导入模块: from template_preprocessor.core.lexer import Token [as 别名]
# 或者: from template_preprocessor.core.lexer.Token import output_as_string [as 别名]
def compile_html_string(html_string, path=""):
    """
    Compile a html string
    """
    # First, create a tree to begin with
    tree = Token(name="root", line=1, column=1, path=path)
    tree.children = [html_string]

    # Tokenize
    tokenize(tree, __HTML_STATES, [Token])

    from template_preprocessor.core.django_processor import PreProcessSettings

    options = PreProcessSettings()
    _process_html_tree(tree, options)

    # Output
    return tree.output_as_string()
开发者ID:bryanveloso,项目名称:django-template-preprocessor,代码行数:20,代码来源:html_processor.py

示例4: compile_javascript_string

# 需要导入模块: from template_preprocessor.core.lexer import Token [as 别名]
# 或者: from template_preprocessor.core.lexer.Token import output_as_string [as 别名]
def compile_javascript_string(js_string, context, path=''):
    """
    Compile JS code (can be used for external javascript files)
    """

    # First, create a tree to begin with
    tree = Token(name='root', line=1, column=1, path=path)
    tree.children = [ js_string ]

    # Tokenize
    with context.time_operation("tokenize string"):
        tokenize(tree, __JS_STATES, Token)

    # Compile
    _compile(tree, context, already_minified=path.endswith(".min.js"))

    # Output
    return tree.output_as_string()
开发者ID:onysos,项目名称:django-template-preprocessor,代码行数:20,代码来源:js_processor.py

示例5: compile_css_string

# 需要导入模块: from template_preprocessor.core.lexer import Token [as 别名]
# 或者: from template_preprocessor.core.lexer.Token import output_as_string [as 别名]
def compile_css_string(css_string, context, path='', url=None):
    """
    Compile CSS code
    """
    # First, create a tree to begin with
    tree = Token(name='root', line=1, column=1, path=path)
    tree.children = [ css_string ]

    # Tokenize
    tokenize(tree, __CSS_STATES, Token)
    _add_css_parser_extensions(tree)

    # Rewrite url() in external css files
    if url:
        _rewrite_urls(tree, url)

    # Compile
    _compress_css_whitespace(tree)

    # Output
    return u''.join([o for o in tree.output_as_string() ])
开发者ID:globocom,项目名称:django-template-preprocessor,代码行数:23,代码来源:css_processor.py

示例6: compile_javascript_string

# 需要导入模块: from template_preprocessor.core.lexer import Token [as 别名]
# 或者: from template_preprocessor.core.lexer.Token import output_as_string [as 别名]
def compile_javascript_string(js_string, path=''):
    """
    Compile JS code (can be used for external javascript files)
    """
    # First, create a tree to begin with
    tree = Token(name='root', line=1, column=1, path=path)
    tree.children = [ js_string ]

    # Tokenize
    tokenize(tree, __JS_STATES, [Token] )

    # Compile
    _add_javascript_parser_extensions(tree)
    _validate_javascript(tree)
    _compress_javascript_whitespace(tree)
    _minify_variable_names(tree)

    fix_whitespace_bug(tree)

    # Output
    return tree.output_as_string()
开发者ID:bryanveloso,项目名称:django-template-preprocessor,代码行数:23,代码来源:js_processor.py

示例7: init_extension

# 需要导入模块: from template_preprocessor.core.lexer import Token [as 别名]
# 或者: from template_preprocessor.core.lexer.Token import output_as_string [as 别名]
 def init_extension(self):
     self.__varname = Token.output_as_string(self, True)
开发者ID:sentido,项目名称:django-template-preprocessor,代码行数:4,代码来源:django_processor.py


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