Skip to content

Commit

Permalink
Log HTML rewriting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kixiron authored and Joshua Nelson committed Aug 4, 2020
1 parent 482d566 commit acc0f06
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 10 deletions.
179 changes: 175 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/utils/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) fn rewrite_lol(

let head_handler = |head: &mut Element| {
head.append(&tera_head, ContentType::Html);

Ok(())
};

Expand Down Expand Up @@ -77,11 +78,14 @@ pub(crate) fn rewrite_lol(

// The input and output are always strings, we just use `&[u8]` so we only have to validate once.
let mut buffer = Vec::new();
// TODO: Make the rewriter persistent?
let mut writer = HtmlRewriter::try_new(settings, |bytes: &[u8]| {
buffer.extend_from_slice(bytes);
})
.expect("utf8 is a valid encoding");

writer.write(html)?;
writer.end()?;

Ok(buffer)
}
Loading

0 comments on commit acc0f06

Please sign in to comment.