コード例 #1
0
ファイル: render.py プロジェクト: exploratour/exploratour
def jsval(value):
    """Format a value as json, and encode suitably for inserting into a script
    element.

    """
    assert not isinstance(value, jinja2.runtime.Undefined)
    value = json.dumps(value, indent=None)
    value = value.replace('<', '<"+"')
    return jinja2.utils.Markup(value)
コード例 #2
0
ファイル: render.py プロジェクト: exploratour/exploratour
def jsvalattr(value):
    """Format a value as json, for use in an attribute value.

    """
    assert not isinstance(value, jinja2.runtime.Undefined)
    return json.dumps(value, indent=None, separators=(',', ':'))