Skip to content

Commit

Permalink
Fix and test FLATPAGES_HTML_RENDERER as a string to import.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Jun 2, 2011
1 parent cdd5d96 commit 5e97223
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion flaskext/flatpages.py
Expand Up @@ -216,7 +216,7 @@ def _parse(self, string, path):

html_renderer = self.app.config['FLATPAGES_HTML_RENDERER']
if not callable(html_renderer):
html_renderer = import_string(html_renderer)
html_renderer = werkzeug.import_string(html_renderer)
return Page(path, meta, content, html_renderer)


13 changes: 7 additions & 6 deletions test_flatpages/__init__.py
Expand Up @@ -145,12 +145,13 @@ def test_other_encoding(self):
self._unicode(pages)

def test_other_html_renderer(self):
pages = FlatPages(Flask(__name__))
pages.app.config['FLATPAGES_HTML_RENDERER'] = unicode.upper
hello = pages.get('hello')
self.assertEquals(hello.body, u'Hello, *世界*!\n')
# Markdow
self.assertEquals(hello.html, u'HELLO, *世界*!\n')
for renderer in (unicode.upper, 'string.upper'):
pages = FlatPages(Flask(__name__))
pages.app.config['FLATPAGES_HTML_RENDERER'] = renderer
hello = pages.get('hello')
self.assertEquals(hello.body, u'Hello, *世界*!\n')
# Upper-case, markdown not interpreted
self.assertEquals(hello.html, u'HELLO, *世界*!\n')

def test_other_extension(self):
app = Flask(__name__)
Expand Down

0 comments on commit 5e97223

Please sign in to comment.