From 4e7bd1dd2c55c5283d0523184f5e5c5520b275a5 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 17 Nov 2016 16:15:08 -0500 Subject: [PATCH] various --- compiler/generate/index.js | 174 ++++++++++++++++++++-------- compiler/generate/utils/__test__.js | 52 ++++----- compiler/index.js | 2 +- test/samples/if-block/_config.js | 12 +- test/test.js | 23 +++- 5 files changed, 185 insertions(+), 78 deletions(-) diff --git a/compiler/generate/index.js b/compiler/generate/index.js index 8cf5e9ad2f..73780e31f8 100644 --- a/compiler/generate/index.js +++ b/compiler/generate/index.js @@ -1,31 +1,39 @@ +import { getLocator } from 'locate-character'; import deindent from './utils/deindent.js'; import walkHtml from './utils/walkHtml.js'; const ROOT = 'options.target'; -export default function generate ( parsed ) { +export default function generate ( parsed, template ) { const counters = { element: 0, text: 0, - anchor: 0 + anchor: 0, + if: 0 }; - const renderBlocks = []; - const updateBlocks = []; - const teardownBlocks = []; - - const codeBlocks = []; + const initStatements = []; + const setStatements = [ deindent` + const oldState = state; + state = Object.assign( {}, oldState, newState ); + ` ]; + const teardownStatements = []; // TODO add contents of