How to use the jinja2.utils.soft_unicode function in Jinja2

To help you get started, we’ve selected a few Jinja2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github piejanssens / premiumizer / lib / jinja2 / filters.py View on Github external
def do_title(s):
    """Return a titlecased version of the value. I.e. words will start with
    uppercase letters, all remaining characters are lowercase.
    """
    rv = []
    for item in re.compile(r'([-\s]+)(?u)').split(soft_unicode(s)):
        if not item:
            continue
        rv.append(item[0].upper() + item[1:].lower())
    return ''.join(rv)
github wwqgtxx / wwqLyParse / wwqLyParse / lib / flask_lib / jinja2 / filters.py View on Github external
def do_capitalize(s):
    """Capitalize a value. The first character will be uppercase, all others
    lowercase.
    """
    return soft_unicode(s).capitalize()
github trailofbits / cb-multios / original-challenges / Mixology / support / mixcodegen / jinja2 / filters.py View on Github external
def do_upper(s):
    """Convert a value to uppercase."""
    return soft_unicode(s).upper()
github wwqgtxx / wwqLyParse / wwqLyParse / lib / flask_lib / jinja2 / filters.py View on Github external
{{ "Hello World"|replace("Hello", "Goodbye") }}
            -> Goodbye World

        {{ "aaaaargh"|replace("a", "d'oh, ", 2) }}
            -> d'oh, d'oh, aaargh
    """
    if count is None:
        count = -1
    if not eval_ctx.autoescape:
        return text_type(s).replace(text_type(old), text_type(new), count)
    if hasattr(old, '__html__') or hasattr(new, '__html__') and \
       not hasattr(s, '__html__'):
        s = escape(s)
    else:
        s = soft_unicode(s)
    return s.replace(soft_unicode(old), soft_unicode(new), count)
github fxgsell / GG-Edge-Inference / device-configuration-tool / jinja2 / filters.py View on Github external
{{ "Hello World"|replace("Hello", "Goodbye") }}
            -> Goodbye World

        {{ "aaaaargh"|replace("a", "d'oh, ", 2) }}
            -> d'oh, d'oh, aaargh
    """
    if count is None:
        count = -1
    if not eval_ctx.autoescape:
        return text_type(s).replace(text_type(old), text_type(new), count)
    if hasattr(old, '__html__') or hasattr(new, '__html__') and \
       not hasattr(s, '__html__'):
        s = escape(s)
    else:
        s = soft_unicode(s)
    return s.replace(soft_unicode(old), soft_unicode(new), count)
github nodejs / abi-stable-node / deps / v8 / third_party / jinja2 / filters.py View on Github external
def do_capitalize(s):
    """Capitalize a value. The first character will be uppercase, all others
    lowercase.
    """
    return soft_unicode(s).capitalize()
github pallets / jinja / jinja2 / filters.py View on Github external
{{ "Hello World"|replace("Hello", "Goodbye") }}
            -> Goodbye World

        {{ "aaaaargh"|replace("a", "d'oh, ", 2) }}
            -> d'oh, d'oh, aaargh
    """
    if count is None:
        count = -1
    if not eval_ctx.autoescape:
        return text_type(s).replace(text_type(old), text_type(new), count)
    if hasattr(old, '__html__') or hasattr(new, '__html__') and \
       not hasattr(s, '__html__'):
        s = escape(s)
    else:
        s = soft_unicode(s)
    return s.replace(soft_unicode(old), soft_unicode(new), count)
github PyAr / CDPedia / src / third_party / jinja2 / filters.py View on Github external
def do_trim(value):
    """Strip leading and trailing whitespace."""
    return soft_unicode(value).strip()
github piejanssens / premiumizer / lib / jinja2 / filters.py View on Github external
def do_format(value, *args, **kwargs):
    """
    Apply python string formatting on an object:

    .. sourcecode:: jinja

        {{ "%s - %s"|format("Hello?", "Foo!") }}
            -> Hello? - Foo!
    """
    if args and kwargs:
        raise FilterArgumentError('can\'t handle positional and keyword '
                                  'arguments at the same time')
    return soft_unicode(value) % (kwargs or args)
github baseblack / ReproWeb / 3rdParty / python / jinja2 / filters.py View on Github external
def do_lower(s):
    """Convert a value to lowercase."""
    return soft_unicode(s).lower()