sauron

Latest Version Build Status MIT licensed

sauron

```log,ignore One crate to rule the DOM One crate to find the elements One crate to bring JSON And in the Rust code bind Strings

This code, no other, is made by code elves Who'd pawn parent process to get it themselves Ruler of net troll and mortal and hacker This code is a lib crate for Patreon backers If trashed or buggy it cannot be remade If found send to Ivan, the bandwidth is prepaid ```

Sauron is an html web framework for building web-apps with the goal of closely adhering to The Elm Architecture, a paragon for elegant design.

As with elm, sauron doesn't use macros to provide the view, instead just using plain rust function calls to construct the view.

Example

```rust use sauron::html::attributes::; use sauron::html::events::; use sauron::html::; use sauron::Component; use sauron::Node; use sauron::Program; use sauron::Cmd; use wasm_bindgen::prelude::;

[derive(Debug, PartialEq, Clone)]

pub enum Msg { Click, }

pub struct App { click_count: u32, }

impl App { pub fn new() -> Self { App { click_count: 0 } } }

impl Component for App {

fn view(&self) -> Node<Msg> {
    div(
        vec![class("some-class"), id("some-id"), attr("data-id", 1)],
        vec![
            input(
                vec![
                    class("client"),
                    r#type("button"),
                    value("Click me!"),
                    onclick(|_| {
                        sauron::log("Button is clicked");
                        Msg::Click
                    }),
                ],
                vec![],
            ),
            text(format!("Clicked: {}", self.click_count)),
        ],
    )
}

fn update(&mut self, msg: Msg) -> Cmd<Self, Msg> {
    sauron::log!("App is updating from msg: {:?}", msg);
    match msg {
        Msg::Click => {
            self.click_count += 1;
            Cmd::none()
        }
    }
}

}

[wasm_bindgen(start)]

pub fn main() { Program::mounttobody(App::new()); } index.html html Minimal sauron app ```

Note: You need to use the nightly compiler with minimum version: rustc 1.37.0-nightly (17e62f77f 2019-07-01)

Build using sh $> wasm-pack build --target no-modules Look at the examples and the build script for the details.

Warning: You need to use the latest nightly compiler in order for this to work.

Prerequisite:

sh cargo install wasm-pack cargo install basic-http-server

This project is based on the existing projects: - percy - yew - willow

Performance:

Benchmark

Please support this project:

Become a patron

Please contact me: ivanceras[at]gmail.com

License: MIT