Skip to content

Commit

Permalink
Include report template into binary.
Browse files Browse the repository at this point in the history
  • Loading branch information
qwandor committed Jul 4, 2024
1 parent b34d480 commit 7869cef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions i18n-report/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use polib::{catalog::Catalog, po_file};
use std::{collections::BTreeMap, fs, path::Path};
use tera::{Context, Tera, Value};

const REPORT_TEMPLATE: &str = include_str!("../templates/report.html");

fn main() -> anyhow::Result<()> {
let args = std::env::args().collect::<Vec<_>>();
let [_, report_file, translations @ ..] = args.as_slice() else {
Expand All @@ -42,10 +44,9 @@ fn main() -> anyhow::Result<()> {
.map(MessageStats::to_context)
.collect::<Vec<_>>();

let tera = Tera::new("templates/*.html")?;
let mut context = Context::new();
context.insert("languages", &languages);
let report = tera.render("report.html", &context)?;
let report = Tera::one_off(REPORT_TEMPLATE, &context, true)?;
fs::write(report_file, report)?;

Ok(())
Expand Down

0 comments on commit 7869cef

Please sign in to comment.