utkarshkukreti / markup.rs

A blazing fast, type-safe template engine for Rust.
Apache License 2.0
363 stars 15 forks source link

Hyphenated attributes throw "error: expected `=`" #9

Closed niallrr closed 4 years ago

niallrr commented 4 years ago

Hyphenated attributes produce the following error. This is important for being able to use Bootstrap.

button [
    type="button",
    class="btn btn-circle btn-dual-secondary d-lg-none align-v-r",
    data-toggle="layout",
    data-action="sidebar_close"
    ]
    {
        i [class="fa fa-times text-danger"]
    }

Throws the error

error: expected `=`
   --> src/t_base.rs:115:29
    |
115 |                         data-toggle="layout",
    |  
niallrr commented 4 years ago

Just found a workaround

    "data-toggle"="layout",
    "data-action"="sidebar_close"
utkarshkukreti commented 4 years ago

Hi, yes, that's the right way. Proc macros in Rust work with Rust tokens, so there's no way to distinguish between data - toggle = "layout" and data-toggle = "layout", which is why I allow string literals on the left of =.

Svenskunganka commented 3 years ago

@utkarshkukreti Is there a similar way to output a hyphenated element?

my-custom-element#id.class {
  @content
}

Currently gives error expected expression pointing at the @content. This is important for custom elements.