1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#![no_std]

struct LitHtml {
    render: js::JSFunction,
}

impl Default for LitHtml {
    fn default() -> Self {
        LitHtml {
            render: js::register_function(
                "function(template,dom){
                template = this.getObject(template);
                dom = this.getObject(dom);
                window.LitHtml.render(template,dom);
            }",
            ),
        }
    }
}

pub fn render<T, R>(template_result: T, dom: R)
where
    T: Into<f64>,
    R: Into<f64>,
{
    let lit_html = globals::get::<LitHtml>();
    lit_html.render.invoke_2(template_result.into(), dom.into());
}

pub trait Template {
    fn execute(&self) -> f64;
}

pub mod globals;
pub mod js;

pub use lit_html_macro::template;