-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
055ef6e
commit 2e85731
Showing
3 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#![no_implicit_prelude] | ||
|
||
// Shadow primitives | ||
#[allow(non_camel_case_types)] | ||
pub struct bool; | ||
#[allow(non_camel_case_types)] | ||
pub struct char; | ||
#[allow(non_camel_case_types)] | ||
pub struct f32; | ||
#[allow(non_camel_case_types)] | ||
pub struct f64; | ||
#[allow(non_camel_case_types)] | ||
pub struct i128; | ||
#[allow(non_camel_case_types)] | ||
pub struct i16; | ||
#[allow(non_camel_case_types)] | ||
pub struct i32; | ||
#[allow(non_camel_case_types)] | ||
pub struct i64; | ||
#[allow(non_camel_case_types)] | ||
pub struct i8; | ||
#[allow(non_camel_case_types)] | ||
pub struct isize; | ||
#[allow(non_camel_case_types)] | ||
pub struct str; | ||
#[allow(non_camel_case_types)] | ||
pub struct u128; | ||
#[allow(non_camel_case_types)] | ||
pub struct u16; | ||
#[allow(non_camel_case_types)] | ||
pub struct u32; | ||
#[allow(non_camel_case_types)] | ||
pub struct u64; | ||
#[allow(non_camel_case_types)] | ||
pub struct u8; | ||
#[allow(non_camel_case_types)] | ||
pub struct usize; | ||
|
||
#[derive(::yew::Properties, ::std::cmp::PartialEq)] | ||
pub struct SimpleProps { | ||
pub test: ::std::string::String, | ||
} | ||
|
||
pub struct Simple; | ||
impl ::yew::Component for Simple { | ||
type Message = (); | ||
type Properties = SimpleProps; | ||
|
||
fn create(_ctx: &::yew::Context<Self>) -> Self { | ||
::std::unimplemented!() | ||
} | ||
|
||
fn view(&self, _ctx: &::yew::Context<Self>) -> ::yew::Html { | ||
::std::unimplemented!() | ||
} | ||
} | ||
|
||
pub struct Fail; | ||
|
||
fn main() { | ||
_ = ::yew::html! { <span { Fail }={ "" } /> }; | ||
|
||
let dyn_prop = || Fail; | ||
_ = ::yew::html! { <span { dyn_prop() }={ "" } /> }; | ||
|
||
_ = ::yew::html! { <Simple { "test" }={ "" } /> } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
error: expected a valid Rust identifier | ||
--> tests/html_macro/dyn-prop-fail.rs:66:34 | ||
| | ||
66 | _ = ::yew::html! { <Simple { "test" }={ "" } /> } | ||
| ^^^^^^ | ||
|
||
error[E0277]: the trait bound `implicit_clone::unsync::IString: From<Fail>` is not satisfied | ||
--> tests/html_macro/dyn-prop-fail.rs:61:9 | ||
| | ||
61 | _ = ::yew::html! { <span { Fail }={ "" } /> }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<Fail>` is not implemented for `implicit_clone::unsync::IString` | ||
| | ||
= help: the following other types implement trait `From<T>`: | ||
<implicit_clone::unsync::IString as From<&'static str>> | ||
<implicit_clone::unsync::IString as From<Cow<'static, str>>> | ||
<implicit_clone::unsync::IString as From<Rc<str>>> | ||
<implicit_clone::unsync::IString as From<String>> | ||
= note: required because of the requirements on the impl of `Into<implicit_clone::unsync::IString>` for `Fail` | ||
= note: this error originates in the macro `::yew::html` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0277]: the trait bound `implicit_clone::unsync::IString: From<Fail>` is not satisfied | ||
--> tests/html_macro/dyn-prop-fail.rs:64:9 | ||
| | ||
64 | _ = ::yew::html! { <span { dyn_prop() }={ "" } /> }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<Fail>` is not implemented for `implicit_clone::unsync::IString` | ||
| | ||
= help: the following other types implement trait `From<T>`: | ||
<implicit_clone::unsync::IString as From<&'static str>> | ||
<implicit_clone::unsync::IString as From<Cow<'static, str>>> | ||
<implicit_clone::unsync::IString as From<Rc<str>>> | ||
<implicit_clone::unsync::IString as From<String>> | ||
= note: required because of the requirements on the impl of `Into<implicit_clone::unsync::IString>` for `Fail` | ||
= note: this error originates in the macro `::yew::html` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#![no_implicit_prelude] | ||
|
||
// Shadow primitives | ||
#[allow(non_camel_case_types)] | ||
pub struct bool; | ||
#[allow(non_camel_case_types)] | ||
pub struct char; | ||
#[allow(non_camel_case_types)] | ||
pub struct f32; | ||
#[allow(non_camel_case_types)] | ||
pub struct f64; | ||
#[allow(non_camel_case_types)] | ||
pub struct i128; | ||
#[allow(non_camel_case_types)] | ||
pub struct i16; | ||
#[allow(non_camel_case_types)] | ||
pub struct i32; | ||
#[allow(non_camel_case_types)] | ||
pub struct i64; | ||
#[allow(non_camel_case_types)] | ||
pub struct i8; | ||
#[allow(non_camel_case_types)] | ||
pub struct isize; | ||
#[allow(non_camel_case_types)] | ||
pub struct str; | ||
#[allow(non_camel_case_types)] | ||
pub struct u128; | ||
#[allow(non_camel_case_types)] | ||
pub struct u16; | ||
#[allow(non_camel_case_types)] | ||
pub struct u32; | ||
#[allow(non_camel_case_types)] | ||
pub struct u64; | ||
#[allow(non_camel_case_types)] | ||
pub struct u8; | ||
#[allow(non_camel_case_types)] | ||
pub struct usize; | ||
|
||
fn main() { | ||
// basic example from https://htmx.org/attributes/hx-on/ | ||
|
||
// repeating attrs is not valid HTMX nor HTML, | ||
// but valid html! (any checks can happen only during runtime) | ||
|
||
// literal | ||
_ = ::yew::html! { <span { "hx-on:click" }={ "alert('Clicked!')" } /> }; | ||
_ = ::yew::html! { <span { "hx-on:click" }={ "alert('Clicked!')" } { "hx-on:click" }={ "alert('Clicked!')" } /> }; | ||
|
||
// expr | ||
let dyn_prop = || ::std::string::ToString::to_string("hx-on:click"); | ||
_ = ::yew::html! { <span { dyn_prop() }={ "alert('Clicked!')" } /> }; | ||
_ = ::yew::html! { <span { dyn_prop() }={ "alert('Clicked!')" } { dyn_prop() }={ "alert('Clicked!')" } /> }; | ||
} |