Sauron is an HTML web framework for building web-apps with the goal of closely adhering to The Elm Architecture, a paragon of elegant design.
Sauron follow Elm's simplistic design of writing view code.
```rust use log::trace; use sauron::html::attributes::attr; use sauron::html::text; use sauron::prelude::*; use sauron::{Cmd, Component, Node, Program};
pub enum Msg { Click, }
pub struct App { click_count: u32, }
impl App { pub fn new() -> Self { App { click_count: 0 } } }
impl Component"Minimal example"
fn update(&mut self, msg: Msg) -> Cmd<Self, Msg> {
trace!("App is updating with msg: {:?}", msg);
match msg {
Msg::Click => self.click_count += 1,
}
Cmd::none()
}
}
pub fn main() { consolelog::initwithlevel(log::Level::Trace).unwrap(); consoleerrorpanichook::setonce(); Program::mountto_body(App::new()); } ```
index.html
html
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<title>Minimal sauron app</title>
</head>
<body>
<script src='pkg/minimal.js'></script>
<script type=module>
window.wasm_bindgen('pkg/minimal_bg.wasm')
.catch(console.error);
</script>
</body>
</html>
In Cargo.toml, specify the crate-type to be cdylib
```toml
[package] name = "minimal" version = "0.1.0" edition = "2018"
[lib] crate-type = ["cdylib"]
[dependencies] sauron = "0.30" consoleerrorpanichook = { version = "0.1"} log = "0.4" consolelog = {version ="0.2", features = ["color"]} ```
Build using
sh
$> wasm-pack build --target no-modules
Look at the examples
and the build script for the details.
html2sauron - A tool to easily convert html into sauron node tree for your views.
sh
cargo install wasm-pack
cargo install basic-http-server
Sauron is one of the fastest.
License: MIT