mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
rename template to source in generator, to avoid confusion
This commit is contained in:
parent
632a980948
commit
26a436fb87
@ -7,7 +7,7 @@ import flattenReference from './utils/flattenReference.js';
|
||||
import visitors from './visitors/index.js';
|
||||
import processCss from './css/process.js';
|
||||
|
||||
export default function generate ( parsed, template, options = {} ) {
|
||||
export default function generate ( parsed, source, options = {} ) {
|
||||
const renderers = [];
|
||||
|
||||
const generator = {
|
||||
@ -42,7 +42,7 @@ export default function generate ( parsed, template, options = {} ) {
|
||||
});
|
||||
},
|
||||
|
||||
code: new MagicString( template ),
|
||||
code: new MagicString( source ),
|
||||
|
||||
components: {},
|
||||
|
||||
@ -100,7 +100,7 @@ export default function generate ( parsed, template, options = {} ) {
|
||||
|
||||
usesRefs: false,
|
||||
|
||||
template
|
||||
source
|
||||
};
|
||||
|
||||
const templateProperties = {};
|
||||
@ -120,9 +120,9 @@ export default function generate ( parsed, template, options = {} ) {
|
||||
generator.code.overwrite( defaultExport.start, defaultExport.declaration.start, `var template = ` );
|
||||
|
||||
let i = defaultExport.start;
|
||||
while ( /\s/.test( template[ i - 1 ] ) ) i--;
|
||||
while ( /\s/.test( source[ i - 1 ] ) ) i--;
|
||||
|
||||
const indentation = template.slice( i, defaultExport.start );
|
||||
const indentation = source.slice( i, defaultExport.start );
|
||||
generator.code.insertLeft( finalNode.end, `\n\n${indentation}return template;` );
|
||||
}
|
||||
|
||||
@ -229,8 +229,6 @@ export default function generate ( parsed, template, options = {} ) {
|
||||
dispatchObservers( observers.deferred, newState, oldState );
|
||||
` );
|
||||
|
||||
const addCss = parsed.css ? processCss( parsed ) : null;
|
||||
|
||||
const constructorName = options.name || 'SvelteComponent';
|
||||
|
||||
const topLevelStatements = [];
|
||||
@ -369,7 +367,7 @@ export default function generate ( parsed, template, options = {} ) {
|
||||
c = part.end;
|
||||
});
|
||||
|
||||
generator.code.remove( c, template.length );
|
||||
generator.code.remove( c, source.length );
|
||||
generator.code.append( finalChunk );
|
||||
|
||||
sortedByResult.forEach( part => {
|
||||
|
@ -10,7 +10,7 @@ export default {
|
||||
const listName = `${name}_value`;
|
||||
|
||||
generator.current.initStatements.push( deindent`
|
||||
var ${name}_anchor = document.createComment( ${JSON.stringify( `#each ${generator.template.slice( node.expression.start, node.expression.end )}` )} );
|
||||
var ${name}_anchor = document.createComment( ${JSON.stringify( `#each ${generator.source.slice( node.expression.start, node.expression.end )}` )} );
|
||||
${generator.current.target}.appendChild( ${name}_anchor );
|
||||
var ${name}_iterations = [];
|
||||
const ${name}_fragment = document.createDocumentFragment();
|
||||
|
@ -9,7 +9,7 @@ export default {
|
||||
const renderer = `renderIfBlock_${i}`;
|
||||
|
||||
generator.current.initStatements.push( deindent`
|
||||
var ${name}_anchor = document.createComment( ${JSON.stringify( `#if ${generator.template.slice( node.expression.start, node.expression.end )}` )} );
|
||||
var ${name}_anchor = document.createComment( ${JSON.stringify( `#if ${generator.source.slice( node.expression.start, node.expression.end )}` )} );
|
||||
${generator.current.target}.appendChild( ${name}_anchor );
|
||||
var ${name} = null;
|
||||
` );
|
||||
@ -22,7 +22,7 @@ export default {
|
||||
let expression;
|
||||
|
||||
if ( isReference( node.expression ) ) {
|
||||
const reference = `${generator.template.slice( node.expression.start, node.expression.end )}`;
|
||||
const reference = `${generator.source.slice( node.expression.start, node.expression.end )}`;
|
||||
expression = usedContexts[0] === 'root' ? `root.${reference}` : reference;
|
||||
|
||||
generator.current.updateStatements.push( deindent`
|
||||
|
@ -17,7 +17,7 @@ export default {
|
||||
const snippet = `[✂${node.expression.start}-${node.expression.end}✂]`;
|
||||
|
||||
if ( isReference( node.expression ) ) {
|
||||
const reference = `${generator.template.slice( node.expression.start, node.expression.end )}`;
|
||||
const reference = `${generator.source.slice( node.expression.start, node.expression.end )}`;
|
||||
const qualified = usedContexts[0] === 'root' ? `root.${reference}` : reference;
|
||||
|
||||
generator.current.updateStatements.push( deindent`
|
||||
|
Loading…
Reference in New Issue
Block a user