0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 01:10:43 +08:00
discourse/frontend/asset-processor/theme-hbs-ast-transforms.js
David Taylor d1e1c02fcb DEV: Rename app/assets/javascripts/ -> frontend/
Commit created with `mv app/assets/javascripts frontend && git add .`
2025-10-22 16:24:11 +01:00

30 lines
804 B
JavaScript
Vendored

function manipulateAstNodeForTheme(node, themeId) {
// Magically add theme id as the first param for each of these helpers)
if (
node.path.head &&
["theme-i18n", "theme-prefix", "theme-setting"].includes(
node.path.head.name
)
) {
if (node.params.length === 1) {
node.params.unshift({
type: "NumberLiteral",
value: themeId,
original: themeId,
loc: { start: {}, end: {} },
});
}
}
}
export default function buildEmberTemplateManipulatorPlugin(themeId) {
return function () {
return {
name: "theme-template-manipulator",
visitor: {
SubExpression: (node) => manipulateAstNodeForTheme(node, themeId),
MustacheStatement: (node) => manipulateAstNodeForTheme(node, themeId),
},
};
};
}