-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.0 Roadmap #1
Comments
Potential interface: use std::collections::HashMap;
type Attributes = HashMap<String, Option<String>>;
type Content = String;
trait Block {
const NAME: &'static str; // or `Cow<'static, str>` for more flexibility
fn attributes(&self) -> &Attributes;
fn attributes_mut(&mut self) -> &mut Attributes;
fn content(&self) -> &Content;
fn content_mut(&mut self) -> &mut Content;
}
trait CustomBlock: Block {/* snip */}
struct Template {/* snip */};
impl Block for Template { /* snip */ }
struct Script {/* snip */};
impl Block for Script { /* snip */ }
struct Style {/* snip */};
impl Block for Style { /* snip */ }
struct Sfc {/* snip */}
impl Sfc {
pub fn new() -> Self;
pub fn template(&self) -> Option<&Template>;
pub fn template_mut(&mut self) -> Option<&mut Template>;
pub fn script(&self) -> Option<&Script>;
pub fn script_mut(&mut self) -> Option<&mut Script>;
pub fn script_setup(&self) -> Option<&Script>;
pub fn script_setup_mut(&self) -> Option<&mut Script>;
pub fn styles(&self) -> &[&Style];
pub fn styles_mut(&self) -> &[&mut Style];
pub fn get<B: CustomBlock>(&self) -> &[&B];
pub fn get_mut<B: CustomBlock>(&self) -> &[&mut B];
} However this raises multiple questions:
|
Because of top-level comments, order matters (comment could refer to something above, below or something else entirely), as such it makes sense to have sorted iterators: impl Sfc {
pub fn iter(&self) -> impl Iterator<Item = &BlockOrComment>;
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut BlockOrComment>;
pub fn into_iter(self) -> impl Iterator<Item = BlockOrComment>;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This describes what I aim to achieve with the crate, not its current state.
Design Goals
Provide an idiomatic API to interact with Vue SFC, this library should let users parse, create, modify and print SFC.
Non-goals
Vue SFC Specifications
From vuejs.org:
template
block.script
block.script setup
block.style
blocks.From the compiler-sfc repo:
template
blocks with nolang
attribute or alang
attribute set tohtml
are to be parsed in Data State.The text was updated successfully, but these errors were encountered: