add preserveWhitespace option

This commit is contained in:
Evan You 2016-04-11 16:27:38 -04:00
parent 8f5a69be8a
commit e094b00c2e
3 changed files with 14 additions and 31 deletions

View File

@ -1,3 +1,4 @@
import config from '../config'
import { parseText } from './text-parser'
import { isArray } from '../util/index'
@ -25,7 +26,7 @@ function genElement (el, key) {
}
function genIf (el, exp) {
return `(${exp}) ? ${genElement(el)} : ''`
return `(${exp}) ? ${genElement(el)} : null`
}
function genFor (el, exp) {
@ -101,7 +102,6 @@ function genData (el, key) {
if (hasEvents) {
data += genEvents(events)
}
console.log(data)
return data.replace(/,$/, '') + '}'
}

View File

@ -1,3 +1,5 @@
import config from '../config'
/**
* Convert HTML string to AST
*
@ -37,8 +39,14 @@ export function parse (html) {
chars (text) {
text = currentParent.tag === 'pre'
? text
: text.trim() ? text : ' '
currentParent.children.push(text)
: text.trim()
? text
: config.preserveWhiteSpace
? ' '
: null
if (text) {
currentParent.children.push(text)
}
}
})
return root

View File

@ -1,13 +1,10 @@
export default {
/**
* Whether to print debug messages.
* Also enables stack trace for warnings.
*
* @type {Boolean}
* Preserve whitespaces between elements.
*/
debug: false,
preserveWhiteSpace: true,
/**
* Whether to suppress warnings.
@ -17,12 +14,6 @@ export default {
silent: false,
/**
* Whether to use async rendering.
*/
async: true,
/**
* Whether to warn against errors caught when evaluating
* expressions.
@ -30,22 +21,6 @@ export default {
warnExpressionErrors: true,
/**
* Whether to allow devtools inspection.
* Disabled by default in production builds.
*/
devtools: process.env.NODE_ENV !== 'production',
/**
* Internal flag to indicate the delimiters have been
* changed.
*
* @type {Boolean}
*/
_delimitersChanged: true,
/**
* List of asset types that a component can own.
*