if block expressions

pull/31/head
Rich-Harris 8 years ago
parent c1204e57b0
commit 49a6aeb190

@ -65,8 +65,7 @@ export default function generate ( parsed, template ) {
each: 0 each: 0
}; };
// TODO add contents of <script> tag, with `export default` replaced with `var template =` // TODO (scoped) css
// TODO css
let current = { let current = {
useAnchor: false, useAnchor: false,
@ -85,18 +84,6 @@ export default function generate ( parsed, template ) {
parent: null parent: null
}; };
function flattenExpression ( node, contexts ) {
const flattened = flattenReference( node );
if ( flattened ) {
if ( flattened.name in contexts ) return flattened.keypath;
// TODO handle globals, e.g. {{Math.round(foo)}}
return `root.${flattened.keypath}`;
}
return 'TODO';
}
parsed.html.children.forEach( child => { parsed.html.children.forEach( child => {
walkHtml( child, { walkHtml( child, {
Element: { Element: {
@ -398,6 +385,7 @@ export default function generate ( parsed, template ) {
name: renderer, name: renderer,
target: 'target', target: 'target',
contexts: current.contexts,
contextChain: current.contextChain, contextChain: current.contextChain,
initStatements: [], initStatements: [],

@ -15,6 +15,8 @@ export default function contextualise ( code, expression, contexts ) {
code.insertRight( node.start, `root.` ); code.insertRight( node.start, `root.` );
if ( !~usedContexts.indexOf( 'root' ) ) usedContexts.push( 'root' ); if ( !~usedContexts.indexOf( 'root' ) ) usedContexts.push( 'root' );
} }
this.skip();
} }
} }
}); });

Loading…
Cancel
Save