Fixes #36 - Deprecate invokeBody for <include>

This commit is contained in:
Patrick Steele-Idem 2015-02-23 17:44:42 -07:00
parent 6889b0a9c5
commit a936c93b4c
5 changed files with 37 additions and 4 deletions

View File

@ -5,6 +5,26 @@ Changelog
## 2.0.x
### 2.0.3
- :exclamation: Fixed #36 - Deprecated - When using `<include>` 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 `<compiler-options>`. Example:
```html
<compiler-options whitespace="preserve" />
A
B
C
```
### 2.0.0

View File

@ -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') {

View File

@ -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(', ') + '}';

View File

@ -1,12 +1,15 @@
<var name="name" value="data.name"/>
<var name="count" value="data.count"/>
<var name="invokeBody" value="data.invokeBody"/>
<var name="body" value="data.body"/>
<div class="nested">
<h1>
Hello $name! You have $count new messages.
</h1>
<p>
${invokeBody()}
$body
</p>
<p>
${data.invokeBody()} <!-- deprecated -->
</p>
</div>

View File

@ -1 +1 @@
Hello Frank! You have 20 new messages.Hello Frank! You have 20 new messages.Hello Frank! You have 20 new messages.<div class="nested"><h1>Hello Frank! You have 20 new messages.</h1><p>Have a <b>wonderful</b> day!</p></div>
Hello Frank! You have 20 new messages.Hello Frank! You have 20 new messages.Hello Frank! You have 20 new messages.<div class="nested"><h1>Hello Frank! You have 20 new messages.</h1><p>Have a <b>wonderful</b> day!</p><p>Have a <b>wonderful</b> day! </p></div>