#svg #html #parser


A library for parsing html syntax

6 releases

0.1.6 Sep 4, 2020
0.1.5 Aug 15, 2020
0.1.4 Jul 21, 2020
0.1.1 Jun 16, 2020

#32 in Images

Download history 19/week @ 2020-06-15 5/week @ 2020-06-22 2/week @ 2020-06-29 17/week @ 2020-07-06 21/week @ 2020-07-13 33/week @ 2020-07-20 9/week @ 2020-07-27 2/week @ 2020-08-03 36/week @ 2020-08-10 16/week @ 2020-08-17 13/week @ 2020-08-24 27/week @ 2020-08-31 28/week @ 2020-09-07

61 downloads per month
Used in 4 crates (3 directly)

MIT license




Latest Version Build Status MIT licensed


One crate to rule the DOM

One crate to mind it

One crate to bring JSON

And in the Rust code bind it

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

-- The Harvard Lampoon & po8

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.


use sauron::prelude::*;
use wasm_bindgen::prelude::*;
use log::*;

#[derive(Debug, PartialEq, Clone)]
pub enum Msg {

pub struct App {
    click_count: u32,

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

impl Component<Msg> for App {

    fn view(&self) -> Node<Msg> {
            [class("some-class"), id("some-id"), attr("data-id", 1)],
                        value("Click me!"),
                        on_click(|_| {
                            trace!("Button is clicked");
                text!("Clicked: {}", self.click_count),

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


pub fn main() {


    <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
    <title>Minimal sauron app</title>
    <script src='pkg/minimal.js'></script>
    <script type=module>

In Cargo.toml, specify the crate-type to be cdylib

crate-type = ["cdylib"]

Build using

$> wasm-pack build --target no-modules

Look at the examples and the build script for the details.

Demo examples

Converting HTML into Sauron's syntax

html2sauron - A tool to easily convert html into sauron node tree for your views.

Note: When writing the view in sauron, just keep in mind that the function name is the element tag you are creating and there is 2 arguments for it. The first argument is an array of the attributes of the element and the second argument is an array of the children of the element.


div!([id("container"),class("hero")], [text("Content goes here")])

div macro call is the element tag. The 1st argument in the call is an array of attributes for the div element expressed in a function call id and class which are valid attributes for a div. The 2nd argument in the call is an array of the children elements, and you can nest as many as you like.


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

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



Please support this project:

Become a patron

License: MIT


~75K SLoC