yew/yew-macro/tests/props_macro/resolve-prop-pass.rs
Simon fa2ab5abe7
Add a macro for building properties outside of html! (#1599)
* remove renamed imports from yew-macro

They add a lot of cognitive overhead and don't provide much benefit in this case.

* just a prototype

* cleanup

* add prop type resolver

* use new props for tags

* silence clippy

* simplify tag parsing

* clean up

* improve names

* fix list span

* new component props parsing

* fix rogue lint

* update tag attribute parsing

* unify prop handling

* add new tests

* integrate prop validation

* improve error span regression

* add docstring

* update tests

* add test for specifying `children` twice

* move properties derive macro

* component transformer documentation

* update properties documentation

* document special properties

* let's try to fix the spellcheck

* let's just use a newer image then

* document `with props` children

* clean up a tad

* is boolean the missing word?
Starting to question the use of this spell checker...

* add the note for the recursion limit back in

* code review

* improve error for duplicate children

* clippyfying

* revert Task: Drop

* HtmlTag -> HtmlElement

* link the issue for prop_or_else

* PropList -> SortedPropList

* use struct syntax

* use html! in transformer demonstration
2020-10-21 14:05:06 +02:00

39 lines
814 B
Rust

use yew::prelude::*;
#[derive(Clone, Properties)]
struct Props {
n: i32,
}
struct MyComp;
impl Component for MyComp {
type Message = ();
type Properties = Props;
fn create(_props: Self::Properties, _link: ComponentLink<Self>) -> Self {
unimplemented!()
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
}
fn compile_pass() {
yew::props!(Props { n: 1 });
yew::props!(self::Props { n: 1 });
yew::props!(MyComp::Properties { n: 2 });
yew::props!(self::MyComp::Properties { n: 3 });
yew::props!(<MyComp as Component>::Properties { n: 5 });
}
fn main() {}