pubdocs.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:site 作者: alphageek-xyz 项目源码 文件源码
def inline_static_file(path, minify=None):
    """
    Outputs the [minified] contents of a given static file.

    For example, to display the minified CSS file "``inline.css``"::

        <style>
            {% inline_static_file 'inline.css' 'css' %}
        </style>

    The optional ``minify`` argument can be one of css, js, or html.
    """
    p = finders.find(path)

    if not p:
        raise RuntimeError('path=%s not found' % path)
    elif os.path.isdir(p):
        raise RuntimeError('path=%s is not a file' % path)

    with open(p, encoding='utf-8') as f:
        if minify == 'js':
            return mark_safe(js_minify(f.read()))
        elif minify == 'css':
            return mark_safe(css_minify(f.read()))
        elif minify == 'html':
            return mark_safe(html_minify(f.read()))
        else:
            return mark_safe(f.read())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号