Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable render helper in block form. #13295

Merged
merged 1 commit into from
Apr 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/ember-template-compiler/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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}.`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
Expand Down