From 7e92d651ba0b0b2fad984cf89bdc93c21829189c Mon Sep 17 00:00:00 2001 From: Brian Hall Date: Mon, 22 Feb 2016 17:27:19 -0800 Subject: [PATCH] changed type compare to instanceof and added test --- shared/helpers/view.js | 2 +- test/shared/helpers/view.test.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/shared/helpers/view.js b/shared/helpers/view.js index e2de6ee..c53c93b 100644 --- a/shared/helpers/view.js +++ b/shared/helpers/view.js @@ -68,7 +68,7 @@ function getClientPlaceholder(viewName, viewOptions, Handlebars) { // create a list of data attributes var attrString = _.inject(viewOptions, function(memo, value, key) { if (_.isArray(value) || _.isObject(value)) { - if (key === '_block' && value.contructor === Handlebars.SafeString) { + if (key === '_block' && value instanceof Handlebars.SafeString) { value = value.string; } else { value = JSON.stringify(value); diff --git a/test/shared/helpers/view.test.js b/test/shared/helpers/view.test.js index 6fc0ded..79e5e6a 100644 --- a/test/shared/helpers/view.test.js +++ b/test/shared/helpers/view.test.js @@ -175,6 +175,22 @@ describe('view', function () { '
' ); }); + + context('when the key is _block and is of type Handlebars.SafeString', function () { + it('extracts the string correctly', function () { + var html = '
something
', + result = subject.call({ + _app: app() + }, 'test', { + hash: { + _block: new Handlebars.SafeString(html) + } + }); + expect(result.string).to.eq( + '
' + ); + }); + }); }); }); });