-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impl fastn_continuation::Continuation for fastn_compiler::Compiler
- Loading branch information
Showing
11 changed files
with
127 additions
and
148 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,27 @@ | ||
impl fastn::commands::Render { | ||
pub async fn run(self, config: &mut fastn_package::Package, _router: fastn_router::Router) { | ||
pub async fn run(self, _package: &mut fastn_package::Package, _router: fastn_router::Router) { | ||
let route = fastn_continuation::consume(fastn_router::Router::reader(), fastn::full_filler) | ||
.route("/", fastn_router::Method::Get, &[]); | ||
match route { | ||
fastn_router::Route::Document(path, data) => { | ||
let html = fastn::commands::render::render_document( | ||
config.auto_imports.clone(), | ||
path.as_str(), | ||
data, | ||
self.strict, | ||
) | ||
.await; | ||
let html = | ||
fastn::commands::render::render_document(path.as_str(), data, self.strict) | ||
.await; | ||
std::fs::write(path.replace(".ftd", ".html"), html).unwrap(); | ||
} | ||
_ => todo!(), | ||
}; | ||
} | ||
} | ||
|
||
pub async fn render_document( | ||
global_aliases: Vec<fastn_package::AutoImport>, | ||
path: &str, | ||
_data: serde_json::Value, | ||
_strict: bool, | ||
) -> String { | ||
pub async fn render_document(path: &str, _data: serde_json::Value, _strict: bool) -> String { | ||
let source = std::fs::File::open(path) | ||
.and_then(std::io::read_to_string) | ||
.unwrap(); | ||
let mut cs = fastn_compiler::compile(&source, "main", None, todo!()); | ||
let mut symbol_store = fastn::Symbols {}; | ||
|
||
let o = loop { | ||
match cs { | ||
fastn_compiler::CompilerState::StuckOnSymbols(mut c, symbols) => { | ||
let o = symbol_store.lookup(&mut c, &symbols).await; | ||
cs = c.continue_with_definitions(o); | ||
} | ||
fastn_compiler::CompilerState::Done(c) => { | ||
break c; | ||
} | ||
} | ||
}; | ||
|
||
let o = fastn_continuation::consume_with( | ||
fastn_compiler::compile(&source, "main", None), | ||
fastn::symbols::lookup, | ||
); | ||
let h = fastn_runtime::HtmlData::from_cd(o.unwrap()); | ||
h.to_test_html() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.