New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue-sfc-descriptor-to-string

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-sfc-descriptor-to-string

Convert SFCDescriptor to source

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

vue-sfc-descriptor-to-string

Convert SFCDescriptor to source

Install

npm install vue-sfc-descriptor-to-string

Usage

// 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

API

const toString = require('vue-sfc-descriptor-to-string');

toString(SFCDescriptor, options)

SFCDescriptor

Object that looks like an SFCDescriptor

options

Optional object, defaults to {}

options.indents

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: 0,
  script: 0,
  style: 0
}

Caveats

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

  • ends with a single newline
  • has a single space before each attribute on <script>, <template>, <style>
  • other stuff

License

MIT

Keywords

FAQs

Package last updated on 11 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc