phoenix-ru / fervid

All-in-One Vue compiler written in Rust
https://phoenix-ru.github.io/fervid/
Apache License 2.0
371 stars 9 forks source link

compile_sync_naive not working properly #32

Closed CCherry07 closed 2 months ago

CCherry07 commented 2 months ago

cargo.toml:

image

code:

use fervid::compile_sync_naive;

use super::CompilerParams;

pub fn vue_compiler(param: CompilerParams) -> String {
  let CompilerParams { svg, .. } = param;
  compile_sync_naive(&svg, true).unwrap()
}

#[cfg(test)]
mod tests {
  use super::*;

  #[test]
  fn test_vue_compiler() {
    let svg = r#"<template>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
    <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-2-6h4v-2h-4v2z"/>
  </svg>
    </template>"#;
    let result = vue_compiler(CompilerParams {
      svg: svg.to_string(),
      root_path: "".to_string(),
    });
  }
}

err:

image
phoenix-ru commented 2 months ago

Hi, thank you for your report. I haven't published the crate for quite a long time and API may be outdated. I can publish a new version, as it is definitely more mature :)

phoenix-ru commented 2 months ago

@CCherry07 I have published a new version 0.2.0, could you please check it out? :slightly_smiling_face:

I would also recommend you use fervid::compile when you need more control, as compile_sync_naive is mostly used for WASM use-cases

CCherry07 commented 2 months ago

@CCherry07 I have published a new version 0.2.0, could you please check it out? 🙂

I would also recommend you use fervid::compile when you need more control, as compile_sync_naive is mostly used for WASM use-cases

thank you !!!

CCherry07 commented 2 months ago

@CCherry07 I have published a new version 0.2.0, could you please check it out? 🙂

I would also recommend you use fervid::compile when you need more control, as compile_sync_naive is mostly used for WASM use-cases

The 0.2.0 version runs very well, thank you for your help.

phoenix-ru commented 2 months ago

@CCherry07 I am closing the issue, feel free to create new issues if you find some other problems with using the crate!