Bakhtina Sofya b84cb877be 1st comm | 2 months ago | |
---|---|---|
.. | ||
__snapshots__ | 2 months ago | |
node_modules | 2 months ago | |
test-components | 2 months ago | |
CHANGELOG.md | 2 months ago | |
LICENSE.mit | 2 months ago | |
README.md | 2 months ago | |
index.js | 2 months ago | |
package.json | 2 months ago | |
test.js | 2 months ago |
Convert SFCDescriptor to source
npm install vue-sfc-descriptor-to-string
// parse an sfc
const compiler = require('vue-template-compiler');
const sfcDescriptor = compiler.parseComponent(sfcSource);
// convert sfc descriptor back to source
const toString = require('vue-sfc-descriptor-to-string');
const result = toString(sfcDescriptor);
result == sfcSource // => true, but see caveats below
const toString = require('vue-sfc-descriptor-to-string');
toString(SFCDescriptor, options)
Object that looks like an SFCDescriptor
Optional object, defaults to {}
Optional object that can have a property for each sfc block name (e.g. template
). Values are the number of spaces to indent that block's content.
Defaults to
{
template: 2,
script: 0,
style: 0
}
This module isn't a true inverse of compiler.parseComponent()
because it doesn't always produce the exact same sfc compared to what was parsed. It assumes the parsed sfc
<script>
, <template>
, <style>
<script>
, <template>
, <style>
MIT