Пример #1
0
    def test_render_theme_template(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        Themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            coolsrc = render_theme_template('cool', 'hello.html').strip()
            plainsrc = render_theme_template('plain', 'hello.html').strip()
            assert coolsrc == 'Hello from Cool Blue v2.'
            assert plainsrc == 'Hello from the application'
Пример #2
0
    def test_active_theme(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        Themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            appdata = render_template('active.html').strip()
            cooldata = render_theme_template('cool', 'active.html').strip()
            plaindata = render_theme_template('plain', 'active.html').strip()
            assert appdata == 'Application, Active theme: none'
            assert cooldata == 'Cool Blue v2, Active theme: cool'
            assert plaindata == 'Application, Active theme: plain'
Пример #3
0
    def test_theme_static(self):
        app = Flask(__name__)
        app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
        Themes(app, app_identifier='testing')

        with app.test_request_context('/'):
            coolurl = static_file_url('cool', 'style.css')
            cooldata = render_theme_template('cool', 'static.html').strip()
            assert cooldata == 'Cool Blue v2, %s' % coolurl
Пример #4
0
def render_template(template, theme=None, **context):
    theme = theme or []
    if not isinstance(theme, (list, tuple)):
        theme = [theme]

    sys_theme = session.get('theme', current_app.config.get('DEFAULT_THEME'))
    if sys_theme:
        theme.append(sys_theme)

    return render_theme_template(theme, template, **context)
Пример #5
0
def render_template(template, theme=None, **context):
    theme = theme or []
    if not isinstance(theme, (list, tuple)):
        theme = [theme]

    sys_theme = session.get('theme', current_app.config.get('DEFAULT_THEME'))
    if sys_theme:
        theme.append(sys_theme)

    return render_theme_template(theme, template, **context)
Пример #6
0
def render(template, **context):
    theme = session.get('theme', app.config['DEFAULT_THEME'])
    return render_theme_template(theme, template, **context)
Пример #7
0
def render_template(template, **context):
    theme = session.get('theme', current_app.config.get('DEFAULT_THEME'))
    return render_theme_template(theme, template, **context)
Пример #8
0
def render(template, **context):
    theme = session.get('theme', app.config['DEFAULT_THEME'])
    return render_theme_template(theme, template, **context)