scss

    SCSS 子集编译器本地候选

    Download zip
    Version
    0.4.0
    License
    MIT
    Last updated
    5 hours ago
    Downloads
    1

    #可执行 API 示例

    增加保留父选择器上下文的嵌套 @media 编译。这些例子调用公开 API,并随 moon test 执行。

    ///|
    test "nested media preserves parent selector" {
    assert_eq(
    @scss.compile(
    ".a{@media (min-width: 600px){color:red;&:hover{color:blue}}}",
    ),
    "@media (min-width: 600px) {\n.a {\n color: red;\n}\n.a:hover {\n color: blue;\n}\n}\n",
    )
    }

    限制:示例只是已实现范围的一部分;完整颜色、标准库、选择器、导入器及源码映射等缺项见 FEATURES.md。

    ParseError

    pub suberror ParseError {
    Invalid(String)
    } derive(
    Debug
    )

    Compilation

    pub(all) struct Compilation {
    css : String
    loaded_files : Array[String]
    diagnostics : Array[String]
    }

    The compiler reads only this caller-supplied virtual filesystem.

    compile

    fn compile(source : String) -> String raise ParseError

    compile_files

    fn compile_files(entry : String, files : Map[String, String]) -> Compilation raise ParseError

    Compile an entry and its SCSS modules without accessing the host filesystem.