コード例 #1
0
ファイル: test_utils.py プロジェクト: weko3-dev35/weko
def test_template_formatting_from_string(app):
    """Test formatting of string-based template to string."""
    with app.app_context():
        out = render_template_to_string("foobar: {{ baz }}",
                                        _from_string=True,
                                        **{'baz': 'spam'})
        assert out == 'foobar: spam'
コード例 #2
0
ファイル: ui.py プロジェクト: weko3-dev35/weko
def format_item(item, template, name='item'):
    """Render a template to a string with the provided item in context."""
    ctx = {name: item}
    return render_template_to_string(template, **ctx)
コード例 #3
0
ファイル: ui.py プロジェクト: tind/invenio-communities
def format_item(item, template, name='item'):
    """Render a template to a string with the provided item in context."""
    ctx = {name: item}
    return render_template_to_string(template, **ctx)
コード例 #4
0
def test_template_formatting_from_string(app):
    """Test formatting of string-based template to string."""
    with app.app_context():
        out = render_template_to_string("foobar: {{ baz }}", _from_string=True,
                                        **{'baz': 'spam'})
        assert out == 'foobar: spam'