|
|
|
@ -53,12 +53,17 @@ function build_locations(locations) {
|
|
|
|
|
* @param {number} [flags]
|
|
|
|
|
*/
|
|
|
|
|
export function transform_template(state, context, namespace, template_name, flags) {
|
|
|
|
|
/**
|
|
|
|
|
* @param {Identifier} template_name
|
|
|
|
|
* @param {Expression[]} args
|
|
|
|
|
*/
|
|
|
|
|
const add_template = (template_name, args) => {
|
|
|
|
|
let call = b.call(get_template_function(namespace, state), ...args);
|
|
|
|
|
const expression =
|
|
|
|
|
state.options.templatingMode === 'functional'
|
|
|
|
|
? template_to_functions(state.template.nodes)
|
|
|
|
|
: template_to_string(state.template.nodes);
|
|
|
|
|
|
|
|
|
|
let call = b.call(
|
|
|
|
|
get_template_function(namespace, state),
|
|
|
|
|
expression,
|
|
|
|
|
flags ? b.literal(flags) : undefined
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (dev) {
|
|
|
|
|
call = b.call(
|
|
|
|
|
'$.add_locations',
|
|
|
|
@ -69,18 +74,4 @@ export function transform_template(state, context, namespace, template_name, fla
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context.state.hoisted.push(b.var(template_name, call));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** @type {Expression[]} */
|
|
|
|
|
const args = [
|
|
|
|
|
state.options.templatingMode === 'functional'
|
|
|
|
|
? template_to_functions(state.template.nodes)
|
|
|
|
|
: template_to_string(state.template.nodes)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (flags) {
|
|
|
|
|
args.push(b.literal(flags));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
add_template(template_name, args);
|
|
|
|
|
}
|
|
|
|
|