ember-source
Version:
A JavaScript framework for creating ambitious web applications
32 lines (29 loc) • 1.01 kB
JavaScript
import '../../../debug/index.js';
import calculateLocationDisplay from '../system/calculate-location-display.js';
import { isPath, trackLocals } from './utils.js';
import { isDevelopingApp } from '@embroider/macros';
import { assert } from '../../../debug/lib/assert.js';
function errorOnInputWithContent(env) {
let moduleName = env.meta?.moduleName;
let {
hasLocal,
visitor
} = trackLocals(env);
return {
name: 'assert-input-helper-without-block',
visitor: {
...visitor,
BlockStatement(node) {
if (hasLocal('input')) return;
if (isPath(node.path) && node.path.original === 'input') {
(isDevelopingApp() && !(false) && assert(assertMessage(moduleName, node)));
}
}
}
};
}
function assertMessage(moduleName, node) {
let sourceInformation = calculateLocationDisplay(moduleName, node.loc);
return `The {{input}} helper cannot be used in block form. ${sourceInformation}`;
}
export { errorOnInputWithContent as default };