Skip to content

Commit

Permalink
Add div-element to wrapper to support cases where only text is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Oct 22, 2018
1 parent 304566d commit 2d89d91
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ report.html
!src/collective
.*.cfg
.Python
Pipfile*
5 changes: 3 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Changelog
1.5 (unreleased)
----------------

- Nothing changed yet.

- Add div-element to wrapper to support cases where only text is provided
(otherwise plone.protect can fail)
[tomgross]

1.4 (2018-09-10)
----------------
Expand Down
22 changes: 17 additions & 5 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,26 @@ flake8-extensions =
[versions]
# Don't use a released version of collective.handlebars
collective.handlebars =

PyMeta3 = 0.5.1
PyYAML = 3.13
chardet = 3.0.4
check-manifest = 0.37
configparser = 3.5.0
coverage = 4.0.3
flake8 = 3.0.4
flake8_coding = 1.3.0
flake8-blind-except = 0.1.1
flake8-coding = 1.3.1
flake8-debugger = 1.4.0
idna = 2.6
mccabe = 0.5.3
plone.recipe.codeanalysis = 3.0.1
plone.recipe.zope2instance = 4.4.0
plone.testing = 5.0.0
coverage = 4.0.3
pybars3 = 0.9.6
pycodestyle = 2.0.0
pyflakes = 1.2.3
python-coveralls = 2.7.0
plone.recipe.zope2instance = 4.4.0
zc.recipe.egg = 2.0.6
setuptools = 33.1.1
sh = 1.12.14
zc.buildout = 2.12.2
zc.recipe.egg = 2.0.6
2 changes: 1 addition & 1 deletion src/collective/handlebars/browser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def translate(self, msgid, domain=None, mapping=None, context=None,
def _wrap_widget(self, render):
if render and render.startswith(u'<html><body>'):
return render
return ''.join([u'<html><body>', render, u'</body></html>'])
return ''.join([u'<html><body><div>', render, u'</div></body></html>'])


class HandlebarsBrowserView(BrowserView, HandlebarsMixin):
Expand Down
8 changes: 4 additions & 4 deletions src/collective/handlebars/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ def test_helpers(self):

def test_render_helper(self):
view = HandlebarsBrowserView(self.portal, self.layer['request'])
rendered = view._wrap_widget('<em>Hello unittest</em>')
rendered = view._wrap_widget('Hello unittest')
self.assertEqual(
rendered, '<html><body><em>Hello unittest</em></body></html>')
rendered, '<html><body><div>Hello unittest</div></body></html>')


class TestPloneView(unittest.TestCase):
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_call_with_template(self):
setattr(tile, 'index', DummyHbsTemplate(self.template_path))
self.assertEqual(
normalize(tile()),
u'<html><body><img src="foo" alt="bar"> </body></html>'
u'<html><body><div><img src="foo" alt="bar"> </div></body></html>'
)

def test_call_with_body_template(self):
Expand Down Expand Up @@ -294,5 +294,5 @@ def test_call_with_template(self):
setattr(tile, 'index', DummyHbsTemplate(self.template_path))
self.assertEqual(
normalize(tile()),
u'<html><body><img src="foo" alt="bar"> </body></html>'
u'<html><body><div><img src="foo" alt="bar"> </div></body></html>'
)

0 comments on commit 2d89d91

Please sign in to comment.