printer-notifications/node_modules/svelte-eslint-parser/lib/parser/converts/mustache.js

44 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2023-11-13 21:10:04 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertDebugTag = exports.convertRawMustacheTag = exports.convertMustacheTag = void 0;
/** Convert for MustacheTag */
function convertMustacheTag(node, parent, ctx) {
return convertMustacheTag0(node, "text", parent, ctx);
}
exports.convertMustacheTag = convertMustacheTag;
/** Convert for MustacheTag */
function convertRawMustacheTag(node, parent, ctx) {
const mustache = convertMustacheTag0(node, "raw", parent, ctx);
const atHtmlStart = ctx.code.indexOf("@html", mustache.range[0]);
ctx.addToken("MustacheKeyword", {
start: atHtmlStart,
end: atHtmlStart + 5,
});
return mustache;
}
exports.convertRawMustacheTag = convertRawMustacheTag;
/** Convert for DebugTag */
function convertDebugTag(node, parent, ctx) {
const mustache = Object.assign({ type: "SvelteDebugTag", identifiers: [], parent }, ctx.getConvertLocation(node));
for (const id of node.identifiers) {
ctx.scriptLet.addExpression(id, mustache, null, (es) => {
mustache.identifiers.push(es);
});
}
const atDebugStart = ctx.code.indexOf("@debug", mustache.range[0]);
ctx.addToken("MustacheKeyword", {
start: atDebugStart,
end: atDebugStart + 6,
});
return mustache;
}
exports.convertDebugTag = convertDebugTag;
/** Convert to MustacheTag */
function convertMustacheTag0(node, kind, parent, ctx) {
const mustache = Object.assign({ type: "SvelteMustacheTag", kind, expression: null, parent }, ctx.getConvertLocation(node));
ctx.scriptLet.addExpression(node.expression, mustache, null, (es) => {
mustache.expression = es;
});
return mustache;
}