Skip to content

richardanaya/vdom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vdom

An elegant vdom inspired by SwiftUI.

use vdom::*;


pub struct TodoItem;

impl TodoItem {
  fn new(s:&str) -> VNode{
    view! {
      Div.add_class("todo-item"){
        Text(s)
      }
    }
  }
}

pub struct TodoList;

impl TodoList {
  fn new(todos:Vec<String>) -> VNode{
    view! {
      Div.add_class("todo-list"){
        For(i in todos.iter()) { TodoItem(i) }
      }
    }
  }
}

fn main() {
    let todos = vec![
      "drink coffee".to_string(),
      "write some code".to_string(),
      "eat lunch".to_string(),
    ];

    let list = TodoList::new(todos);

    println!("{}", list.render_to_string());
}

About

A virtual dom for Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages