See Changelog for recent features.
Go to TUTORIAL if you want to try.
Dependencies:
toml
vertigo = "0.1.0-beta.5"
Example 1:
```rust use vertigo::{dom, DomElement, Value, bind, start_app};
pub fn render(count: Value
let decrement = bind(&count).call(|context, count| {
count.set(count.get(context) - 1);
});
dom! {
<div>
<p>"Counter: " { count }</p>
<button on_click={decrement}>"-"</button>
<button on_click={increment}>"+"</button>
</div>
}
}
pub fn startapplication() { startapp(|| -> DomElement { let count = Value::new(0); render(count) }); } ```
Example 2:
```rust use vertigo::{DomElement, Value, dom, css_fn};
pub struct MyMessage {
pub message: Value
impl MyMessage { pub fn mount(self) -> DomElement { dom! {
"Message to the world: " { self.message }
} } }cssfn! { maindiv, " color: darkblue; " }
fn render() -> DomElement { let message = Value::new("Hello world!".to_string());
dom! {
<div css={main_div()}>
<MyMessage message={message} />
</div>
}
} ```
Take a look at More examples here.
Make sure you're using nigthly version of rust:
rustup default nightly
Install cargo-make that takes care of all other dependencies:
cargo install cargo-make
Build and run project using:
cargo make demo-start
Eventually terminal will let you know that app is available under http://localhost:3000/
If you want to play around with the code, you can make cargo to watch for your changes:
cargo make demo-watch
Keep in mind that you still need to refresh page in the browser after project recompiles.
To compile all examples run:
cargo make examples-build
This will build examples in examples/build
directory. Now point your browser to index.html
file of a particular example.