decorators.py 文件源码

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

项目:wagtaildraftail 作者: springload 项目源码 文件源码
def Link(props):
    link_type = props.get('linkType', '')
    title = props.get('title')

    if link_type == 'page':
        try:
            page_id = props.get('id')
            page = Page.objects.get(id=page_id)
            href = page.url
        except Page.DoesNotExist:
            href = props.get('url', MISSING_RESOURCE_URL)
    else:
        href = props.get('url', MISSING_RESOURCE_URL)

    anchor_properties = {
        'href': href
    }

    if title is not None:
        anchor_properties['title'] = title

    return DOM.create_element('a', anchor_properties, props['children'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号