diff --git a/CHANGELOG.md b/CHANGELOG.md index 81144aa18..ccd47b546 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,26 @@ Changelog ## 2.0.x +### 2.0.3 + +- :exclamation: Fixed #36 - Deprecated - When using `` with body content, nested body content is now passed in as `String` property named `body`. Old behavior: nested content would be passed in as a `Function` property named `invokeBody` that would return the `String` value of the nested content. `invokeBody()` has been deprecated. + +### 2.0.2 + +- :exclamation: Fixed #36 - Deprecated `input.invokeBody()` in favor of `input.renderBody(out)` +- Fixed #37 - Duplicate input property for custom tag renderers + +### 2.0.1 + +- Fixed #35 - Added support for ``. Example: + +```html + +A +B +C +``` + ### 2.0.0 diff --git a/runtime/helpers.js b/runtime/helpers.js index 49d44f0a8..4eb81a97d 100644 --- a/runtime/helpers.js +++ b/runtime/helpers.js @@ -174,6 +174,16 @@ module.exports = { return; } + if (data.body) { + data.invokeBody = function() { + if (!WARNED_INVOKE_BODY) { + WARNED_INVOKE_BODY = 1; + logger.warn('data.invokeBody() deprecated. Use data.body instead.', new Error().stack); + } + return data.body; + }; + } + if (typeof path === 'string') { runtime.render(path, data, out); } else if (typeof path.render === 'function') { diff --git a/taglibs/core/IncludeNode.js b/taglibs/core/IncludeNode.js index 213f0a313..bca3dfb96 100644 --- a/taglibs/core/IncludeNode.js +++ b/taglibs/core/IncludeNode.js @@ -65,7 +65,7 @@ IncludeNode.prototype = { }, _this); if (_this.hasChildren()) { - propParts.push(stringify('invokeBody') + ': ' + _this.getBodyContentFunctionExpression(template, false)); + propParts.push(stringify('body') + ': ' + _this.getBodyContentExpression(template, false)); } return '{' + propParts.join(', ') + '}'; diff --git a/test/test-project/html-templates/include-nested-content.marko b/test/test-project/html-templates/include-nested-content.marko index 94d625172..f70c489fb 100644 --- a/test/test-project/html-templates/include-nested-content.marko +++ b/test/test-project/html-templates/include-nested-content.marko @@ -1,12 +1,15 @@ - +

Hello $name! You have $count new messages.

- ${invokeBody()} + $body +

+

+ ${data.invokeBody()}

\ No newline at end of file diff --git a/test/test-project/html-templates/include.marko.expected.html b/test/test-project/html-templates/include.marko.expected.html index 3456e97af..e65a6d66b 100644 --- a/test/test-project/html-templates/include.marko.expected.html +++ b/test/test-project/html-templates/include.marko.expected.html @@ -1 +1 @@ -Hello Frank! You have 20 new messages.Hello Frank! You have 20 new messages.Hello Frank! You have 20 new messages.

Hello Frank! You have 20 new messages.

Have a wonderful day!

\ No newline at end of file +Hello Frank! You have 20 new messages.Hello Frank! You have 20 new messages.Hello Frank! You have 20 new messages.

Hello Frank! You have 20 new messages.

Have a wonderful day!

Have a wonderful day!

\ No newline at end of file