Create stub renderer for sciter, just to check it works
This commit is contained in:
parent
24bb775f25
commit
1e5a3ccab6
4 changed files with 30 additions and 4 deletions
|
@ -1,9 +1,6 @@
|
||||||
use config::Config;
|
use config::Config;
|
||||||
|
|
||||||
|
use renderers::stub;
|
||||||
fn stub(config: Config, input: String) -> Result<String, String> {
|
|
||||||
return Ok(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn render(config: Config, input: String) -> Result<String, String> {
|
pub fn render(config: Config, input: String) -> Result<String, String> {
|
||||||
let mut rendered_input = input;
|
let mut rendered_input = input;
|
||||||
|
|
|
@ -18,6 +18,7 @@ mod input;
|
||||||
mod utils;
|
mod utils;
|
||||||
mod build;
|
mod build;
|
||||||
mod output;
|
mod output;
|
||||||
|
mod renderers;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
10
src/renderers/mod.rs
Normal file
10
src/renderers/mod.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use config::Config;
|
||||||
|
|
||||||
|
pub mod sciter;
|
||||||
|
|
||||||
|
pub fn stub(config: Config, input: String) -> Result<String, String> {
|
||||||
|
let root = sciter::sciter_start(input);
|
||||||
|
let html = sciter::get_html(root);
|
||||||
|
return Ok(html);
|
||||||
|
}
|
||||||
|
|
18
src/renderers/sciter.rs
Normal file
18
src/renderers/sciter.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
use sciter::{Window, Host, Element};
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
|
|
||||||
|
fn get_root(frame: Window) -> Element {
|
||||||
|
return frame.get_host().deref().get_root().expect("Failed to get root of window");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn sciter_start(source: String) -> Element {
|
||||||
|
let mut frame = Window::new();
|
||||||
|
frame.load_html(&source.as_bytes(), None);
|
||||||
|
return get_root(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_html(element: Element) -> String {
|
||||||
|
return String::from_utf8(element.get_html(true)).expect("Failed to get HTML from element");
|
||||||
|
}
|
Reference in a new issue