helpers.py 文件源码

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

项目:Prism 作者: Stumblinbear 项目源码 文件源码
def locale_(plugin_id, s):
    """ Search the plugin that's rendering the template
    for the requested locale """
    if plugin_id == 'prism':
        ns = prism.settings.PRISM_LOCALE[s]
    else:
        plugin = prism.get_plugin(plugin_id)

        if plugin is None:
            logging.output('Unknown plugin ID. Offender: %s' % plugin_id)
            return s

        ns = plugin.locale[s]

    if s == ns:
        return s

    ns = publish_string(ns, writer=html_fragment_writer).decode('utf-8').rstrip('\r\n')
    if '<p>' not in ns:
        return ''

    ns = ns.split('<p>', 1)[1]
    ns = ns[:ns.rfind('</p>')]
    return jinja2.Markup(ns)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号