diff --git a/packages/ember-template-compiler/lib/index.js b/packages/ember-template-compiler/lib/index.js index 3af84956ae7..02633401076 100644 --- a/packages/ember-template-compiler/lib/index.js +++ b/packages/ember-template-compiler/lib/index.js @@ -14,7 +14,7 @@ import TransformAngleBracketComponents from 'ember-template-compiler/plugins/tra import TransformInputOnToOnEvent from 'ember-template-compiler/plugins/transform-input-on-to-onEvent'; import TransformTopLevelComponents from 'ember-template-compiler/plugins/transform-top-level-components'; import DeprecateRenderModel from 'ember-template-compiler/plugins/deprecate-render-model'; -import DeprecateRenderBlock from 'ember-template-compiler/plugins/deprecate-render-block'; +import PreventRenderBlock from 'ember-template-compiler/plugins/prevent-render-block'; import TransformInlineLinkTo from 'ember-template-compiler/plugins/transform-inline-link-to'; import AssertNoViewAndControllerPaths from 'ember-template-compiler/plugins/assert-no-view-and-controller-paths'; import AssertNoViewHelper from 'ember-template-compiler/plugins/assert-no-view-helper'; @@ -33,7 +33,7 @@ registerPlugin('ast', TransformAngleBracketComponents); registerPlugin('ast', TransformInputOnToOnEvent); registerPlugin('ast', TransformTopLevelComponents); registerPlugin('ast', DeprecateRenderModel); -registerPlugin('ast', DeprecateRenderBlock); +registerPlugin('ast', PreventRenderBlock); registerPlugin('ast', AssertNoEachIn); registerPlugin('ast', TransformInlineLinkTo); diff --git a/packages/ember-template-compiler/lib/plugins/deprecate-render-block.js b/packages/ember-template-compiler/lib/plugins/deprecate-render-block.js deleted file mode 100644 index c4949ad02bb..00000000000 --- a/packages/ember-template-compiler/lib/plugins/deprecate-render-block.js +++ /dev/null @@ -1,41 +0,0 @@ -import { deprecate } from 'ember-metal/debug'; -import calculateLocationDisplay from - 'ember-template-compiler/system/calculate-location-display'; - -export default function DeprecateRenderBlock(options) { - this.syntax = null; - this.options = options; -} - -DeprecateRenderBlock.prototype.transform = - function DeprecateRenderBlock_transform(ast) { - let moduleName = this.options.moduleName; - let walker = new this.syntax.Walker(); - - walker.visit(ast, function(node) { - if (!validate(node)) { return; } - - deprecate( - deprecationMessage(moduleName, node), - false, - { - id: 'ember-template-compiler.deprecate-render-block', - until: '2.4.0', - url: 'http://emberjs.com/deprecations/v2.x#toc_render-helper-with-block' - } - ); - }); - - return ast; -}; - -function validate(node) { - return (node.type === 'BlockStatement') && - (node.path.original === 'render'); -} - -function deprecationMessage(moduleName, node) { - let sourceInformation = calculateLocationDisplay(moduleName, node.loc); - - return `Usage of \`render\` in block form is deprecated ${sourceInformation}.`; -} diff --git a/packages/ember-template-compiler/lib/plugins/prevent-render-block.js b/packages/ember-template-compiler/lib/plugins/prevent-render-block.js new file mode 100644 index 00000000000..9dbad3e0405 --- /dev/null +++ b/packages/ember-template-compiler/lib/plugins/prevent-render-block.js @@ -0,0 +1,33 @@ +import Error from 'ember-metal/error'; +import calculateLocationDisplay from + 'ember-template-compiler/system/calculate-location-display'; + +export default function PreventRenderBlock(options) { + this.syntax = null; + this.options = options; +} + +PreventRenderBlock.prototype.transform = + function PreventRenderBlock_transform(ast) { + let moduleName = this.options.moduleName; + let walker = new this.syntax.Walker(); + + walker.visit(ast, function(node) { + if (!validate(node)) { return; } + + throw new Error(assertionMessage(moduleName, node)); + }); + + return ast; +}; + +function validate(node) { + return (node.type === 'BlockStatement') && + (node.path.original === 'render'); +} + +function assertionMessage(moduleName, node) { + let sourceInformation = calculateLocationDisplay(moduleName, node.loc); + + return `Usage of \`render\` in block form is unsupported ${sourceInformation}.`; +} diff --git a/packages/ember-template-compiler/tests/plugins/deprecate-render-block-test.js b/packages/ember-template-compiler/tests/plugins/deprecate-render-block-test.js index 90aa57b7368..fa4d94bfca9 100644 --- a/packages/ember-template-compiler/tests/plugins/deprecate-render-block-test.js +++ b/packages/ember-template-compiler/tests/plugins/deprecate-render-block-test.js @@ -6,12 +6,12 @@ if (!isEnabled('ember-glimmer')) { QUnit.module('ember-template-compiler: deprecate-render-block'); - QUnit.test('Using `render` with a block issues a deprecation', function() { + QUnit.test('Using `render` with a block throws an error', function() { expect(1); - let expectedMessage = `Usage of \`render\` in block form is deprecated ('baz/foo-bar' @ L1:C0) .`; + let expectedMessage = `Usage of \`render\` in block form is unsupported ('baz/foo-bar' @ L1:C0) .`; - expectDeprecation(function() { + throws(function() { compile('{{#render "foo-bar"}}{{/render}}', { moduleName: 'baz/foo-bar' });