Commits

Thomas Waldmann committed 91b9ba6

trying to fix flask-themes' theme template loader for flask >= 0.8

the issue was that it did not load templates from the theme's templates/
dir when the blueprints are used (which is the case for recent flask).

this changeset fixes this, i hope it did not break something else.

Comments (0)

Files changed (2)

flaskext/themes.py

 @contextfunction
 def global_theme_template(ctx, templatename, fallback=True):
     theme = active_theme(ctx)
-    templatepath = '_themes/%s/%s' % (theme, templatename)
+    if USING_BLUEPRINTS:
+        fmt = '%s/%s'
+    else:
+        fmt = '_themes/%s/%s'
+    templatepath = fmt % (theme, templatename)
     if (not fallback) or template_exists(templatepath):
         return templatepath
     else:

tests/test-themes.py

         setup_themes(app, app_identifier='testing')
         
         with app.test_request_context('/'):
-            assert template_exists('hello.html')
-            assert template_exists('_themes/cool/hello.html')
-            assert not template_exists('_themes/plain/hello.html')
+            if USING_BLUEPRINTS:
+                assert template_exists('hello.html')
+                assert template_exists('cool/hello.html')
+                assert not template_exists('plain/hello.html')
+            else:
+                assert template_exists('hello.html')
+                assert template_exists('_themes/cool/hello.html')
+                assert not template_exists('_themes/plain/hello.html')
     
     def test_loader(self):
         app = Flask(__name__)