squark 0.4.0

Virtual DOM implemention and application definition inspired from HyperApp
docs.rs failed to build squark-0.4.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: squark-0.7.1

squark

crates.io docs.rs

Virtual DOM implemention and application definition inspired from HyperApp.

squark-macros

crates.io docs.rs

Crate that providing JSX like macro by proc_marco and pest parser.

Syntax

view! {
    <button class="clear-completed" onclick={ handler((), move |_| { Some(Action::Submit) }) }>
        Submit
    </button>
}

squark-stdweb

crates.io docs.rs

Squark runtime implemention for web browser with usinng stdweb.

Here is full example of counter app!

#![feature(proc_macro)]

extern crate squark;
extern crate squark_macros;
extern crate squark_stdweb;
extern crate stdweb;

use stdweb::traits::*;
use stdweb::web::document;
use squark::{handler, App, View, Runtime};
use squark_stdweb::StdwebRuntime;
use squark_macros::view;

#[derive(Clone, Debug, PartialEq)]
struct State {
    count: isize,
}

impl State {
    pub fn new() -> State {
        State { count: 0 }
    }
}

#[derive(Clone, Debug)]
enum Action {
    Increment,
    Decrement,
}

#[derive(Clone, Debug)]
struct CounterApp;
impl App for CounterApp {
    type State = State;
    type Action = Action;

    fn reducer(mut state: State, action: Action) -> State {
        match action {
            Action::Increment => {
                state.count += 1;
            }
            Action::Decrement => {
                state.count -= 1;
            }
        };
        state
    }

    fn view(state: State) -> View<Action> {
        view! {
            <div>
                { state.count.to_string() }
                <button onclick={ handler((), |_| Some(Action::Increment)) }>
                    increment
                </button>
                <button onclick={ handler((), |_| Some(Action::Decrement)) }>
                    decrement
                </button>
            </div>
        }
    }
}

fn main() {
    stdweb::initialize();
    StdwebRuntime::<CounterApp>::new(
        document().query_selector("body").unwrap().unwrap(),
        State::new(),
    ).run();
    stdweb::event_loop();
}

Project dir is located at examples/counter.

It is also available TodoMVC example at examples/todomvc and working on https://rail44.github.io/squark/.