Skip to content

Instantly share code, notes, and snippets.

@aimozg
Last active January 28, 2020 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aimozg/c073eea5a55062e3dcd8f887a8567807 to your computer and use it in GitHub Desktop.
Save aimozg/c073eea5a55062e3dcd8f887a8567807 to your computer and use it in GitHub Desktop.
const compiler = require('vue-template-compiler');
const template = '<p>a&nbsp;b</p>';
console.log('----','template');
console.log(template);
for (let opt of ['preserve','condense',undefined]) {
let x = compiler.compile(template, {whitespace: opt});
console.log('\n----','whitespace:',opt);
console.log(x.render);
console.log(x.render.indexOf('\xA0') >=0 ? 'NBSP FOUND': 'NBSP NOT FOUND');
}
---- template
<p>a&nbsp;b</p>
---- whitespace: preserve
with(this){return _c('p',[_v("a b")])}
NBSP FOUND
---- whitespace: condense
with(this){return _c('p',[_v("a b")])}
NBSP NOT FOUND
---- whitespace: undefined
with(this){return _c('p',[_v("a b")])}
NBSP FOUND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment