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


Python html.format_html_join方法代码示例

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


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

示例1: render

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def render(self, name, value, attrs):
        encoded = value
        final_attrs = self.build_attrs(attrs)

        if not encoded or encoded.startswith(UNUSABLE_PASSWORD_PREFIX):
            summary = mark_safe("<strong>%s</strong>" % ugettext("No password set."))
        else:
            try:
                hasher = identify_hasher(encoded)
            except ValueError:
                summary = mark_safe("<strong>%s</strong>" % ugettext(
                    "Invalid password format or unknown hashing algorithm."))
            else:
                summary = format_html_join('',
                                           "<strong>{}</strong>: {} ",
                                           ((ugettext(key), value)
                                            for key, value in hasher.safe_summary(encoded).items())
                                           )

        return format_html("<div{}>{}</div>", flatatt(final_attrs), summary) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:22,代码来源:forms.py

示例2: flatatt

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def flatatt(attrs):
    """
    Convert a dictionary of attributes to a single string.
    The returned string will contain a leading space followed by key="value",
    XML-style pairs. In the case of a boolean value, the key will appear
    without a value. It is assumed that the keys do not need to be
    XML-escaped. If the passed dictionary is empty, then return an empty
    string.

    The result is passed through 'mark_safe' (by way of 'format_html_join').
    """
    key_value_attrs = []
    boolean_attrs = []
    for attr, value in attrs.items():
        if isinstance(value, bool):
            if value:
                boolean_attrs.append((attr,))
        elif value is not None:
            key_value_attrs.append((attr, value))

    return (
        format_html_join('', ' {}="{}"', sorted(key_value_attrs)) +
        format_html_join('', ' {}', sorted(boolean_attrs))
    ) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:26,代码来源:utils.py

示例3: editor_js

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def editor_js():
    # Add extra JS files to the admin
    js_files = [
        'js/hallo-custom.js',
    ]
    js_includes = format_html_join(
        '\n', '<script src="{0}{1}"></script>',
        ((settings.STATIC_URL, filename) for filename in js_files)
    )

    return js_includes + format_html(
        """
        <script>
            registerHalloPlugin('blockquotebutton');
            registerHalloPlugin('blockquotebuttonwithclass');
        </script>
        """
    ) 
开发者ID:chrisdev,项目名称:wagtail-cookiecutter-foundation,代码行数:20,代码来源:wagtail_hooks.py

示例4: validation_error

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def validation_error(request, message, form, buttons=None):
    if not form.non_field_errors():
        # just output the generic "there were validation errors" message, and leave
        # the per-field highlighting to do the rest
        detail = ''
    else:
        # display the full list of field and non-field validation errors
        all_errors = []
        for field_name, errors in form.errors.items():
            if field_name == NON_FIELD_ERRORS:
                prefix = ''
            else:
                try:
                    field_label = form[field_name].label
                except KeyError:
                    field_label = field_name
                prefix = "%s: " % field_label

            for error in errors:
                all_errors.append(prefix + error)

        errors_html = format_html_join('\n', '<li>{}</li>', ((e,) for e in all_errors))
        detail = format_html("""<ul class="errorlist">{}</ul>""", errors_html)

    return messages.error(request, render(message, buttons, detail=detail)) 
开发者ID:wagtail,项目名称:wagtail,代码行数:27,代码来源:messages.py

示例5: flatatt

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def flatatt(attrs):
    """
    Convert a dictionary of attributes to a single string.
    The returned string will contain a leading space followed by key="value",
    XML-style pairs. In the case of a boolean value, the key will appear
    without a value. It is assumed that the keys do not need to be
    XML-escaped. If the passed dictionary is empty, then return an empty
    string.

    The result is passed through 'mark_safe' (by way of 'format_html_join').
    """
    key_value_attrs = []
    boolean_attrs = []
    for attr, value in attrs.items():
        if isinstance(value, bool):
            if value:
                boolean_attrs.append((attr,))
        else:
            key_value_attrs.append((attr, value))

    return (
        format_html_join('', ' {}="{}"', sorted(key_value_attrs)) +
        format_html_join('', ' {}', sorted(boolean_attrs))
    ) 
开发者ID:drexly,项目名称:openhgsenti,代码行数:26,代码来源:utils.py

示例6: insert_editor_js

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def insert_editor_js():
    js_files = [
        # We require this file here to make sure it is loaded before the other.
        'wagtailadmin/js/draftail.js',
        'colourpicker/js/colourpicker.js',
    ]
    js_includes = format_html_join(
        '\n',
        '<script src="{0}"></script>',
        ((static(filename), ) for filename in js_files)
    )
    js_includes += format_html(
        "<script>window.chooserUrls.colourChooser = '{0}';</script>",
        reverse('wagtailcolourpicker:chooser')
    )
    return js_includes 
开发者ID:AccentDesign,项目名称:wagtailcolourpicker,代码行数:18,代码来源:wagtail_hooks.py

示例7: _render_readonly

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def _render_readonly(self, name, value, attrs=None, renderer=None, request=None, form=None, initial_value=None):
        if request and value and isinstance(value, (list, tuple)):
            rendered_values = []
            for value_item in value:
                choice = self._choice(value_item)
                if choice:
                    value_item = force_text(choice[1])
                    if choice.obj:
                        rendered_values.append(self._render_object(request, choice.obj, value_item))
                    else:
                        rendered_values.append(value_item)
            return format_html(
                '<p>{}</p>',
                format_html_join(', ', '{}', ((v,) for v in rendered_values)) if rendered_values else EMPTY_VALUE
            )
        else:
            return super(ModelObjectReadonlyWidget, self)._render_readonly(
                name, value, attrs, renderer, request, form, initial_value
            ) 
开发者ID:matllubos,项目名称:django-is-core,代码行数:21,代码来源:widgets.py

示例8: editor_js

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def editor_js():
    js_files = [
        'js/contact_person_slug.js',
    ]
    js_includes = format_html_join('\n', '<script src="{0}{1}"></script>',
                                   ((settings.STATIC_URL, filename)
                                    for filename in js_files)
                                   )
    return js_includes 
开发者ID:WesternFriend,项目名称:WF-website,代码行数:11,代码来源:wagtail_hooks.py

示例9: as_ul

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def as_ul(self):
        if not self:
            return ''
        return format_html(
            '<ul class="errorlist">{}</ul>',
            format_html_join('', '<li>{}{}</li>', self.items())
        ) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:9,代码来源:utils.py

示例10: editor_css

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def editor_css():
    # Add extra CSS files to the admin like font-awesome
    css_files = [
        'node_modules/font-awesome/css/font-awesome.min.css'
    ]

    css_includes = format_html_join(
        '\n', '<link rel="stylesheet" href="{0}{1}">',
        ((settings.STATIC_URL, filename) for filename in css_files)
    )

    return css_includes 
开发者ID:chrisdev,项目名称:wagtail-cookiecutter-foundation,代码行数:14,代码来源:wagtail_hooks.py

示例11: include_regexps_

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def include_regexps_(obj):
        return format_html_join('\n', '<pre>{}</pre>',
                                ((r,) for r in
                                 obj.include_regexps.split('\n'))) if obj.field and obj.include_regexps else None 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:6,代码来源:admin.py

示例12: exclude_regexps_

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def exclude_regexps_(obj: DocumentFieldDetector):
        return format_html_join('\n', '<pre>{}</pre>',
                                ((r,) for r in
                                 obj.exclude_regexps.split('\n'))) if obj.field and obj.exclude_regexps else None 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:6,代码来源:admin.py

示例13: definition_words_

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def definition_words_(obj: DocumentFieldDetector):
        return format_html_join('\n', '<pre>{}</pre>',
                                ((r,) for r in
                                 obj.definition_words.split('\n'))) if obj.field and obj.definition_words else None 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:6,代码来源:admin.py

示例14: _password_validators_help_text_html

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def _password_validators_help_text_html(password_validators=None):
    """
    Return an HTML string with all help texts of all configured validators
    in an <ul>.
    """
    help_texts = password_validators_help_texts(password_validators)
    help_items = format_html_join('', '<li>{}</li>', ((help_text,) for help_text in help_texts))
    return format_html('<ul>{}</ul>', help_items) if help_items else '' 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:10,代码来源:password_validation.py

示例15: htmlvalue

# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import format_html_join [as 别名]
def htmlvalue(self, val):
        htmlvalues = []
        for name, block in self.block.child_blocks.items():
            label = self.block.child_blocks[name].label
            comparison_class = get_comparison_class_for_block(block)

            htmlvalues.append((label, comparison_class(block, True, True, val[name], val[name]).htmlvalue(val[name])))

        return format_html('<dl>\n{}\n</dl>', format_html_join(
            '\n', '    <dt>{}</dt>\n    <dd>{}</dd>', htmlvalues)) 
开发者ID:wagtail,项目名称:wagtail,代码行数:12,代码来源:compare.py


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