Skip to content

Commit

Permalink
handle liquid parser errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnxpl0it committed Dec 31, 2024
1 parent 7c9d547 commit 099c0e8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/templates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@ impl Template {
fs::write(dest, toml_string).unwrap();
}

//TODO: maybe move this to utils or just crate a submodule for it
pub fn liquify(string: &str) -> String {
let parser = liquid::ParserBuilder::with_stdlib().build().unwrap();
let empty_globals = liquid::Object::new();

parser
.parse(string)
.unwrap()
.render(&empty_globals)
.unwrap()
match parser.parse(string) {
Ok(template) => template.render(&empty_globals).unwrap(),
Err(e) => {
eprintln!("{} parsing template: {}","error".red().bold(), e);
String::new()
}
}
}

fn handle_project_name(
Expand Down

0 comments on commit 099c0e8

Please sign in to comment.