Function parse

Source
pub fn parse(input: &str) -> Result<Vec<Section<'_>>, ParseError>
Expand description

Parse the given input as a Vue SFC.

§Errors

Will return an error if parsing fails.

§Example

use vue_sfc::{Section, Block};

let sfc = vue_sfc::parse("<!-- your input -->").unwrap();

for section in sfc {
    match section {
        Section::Block(Block { name, attributes, content }) => {
            println!(
                "Got a block named `{}` with {} attributes, content is {} bytes long.",
                name,
                attributes.len(),
                content.len()
            )
        }
        Section::Raw(content) => {
            println!(
                "Got a raw section, {} bytes long.",
                content.len()
            )
        }
    }
}