1
Fork 0
mirror of https://github.com/redstrate/Auracite.git synced 2025-07-01 18:17:46 +00:00
auracite/src/html.rs

47 lines
1.7 KiB
Rust
Raw Normal View History

2024-09-29 17:45:53 -04:00
use crate::data::CharacterData;
2025-03-31 16:07:31 -04:00
use minijinja::{Environment, context};
2024-09-29 17:45:53 -04:00
/// Writes a visual HTML for `char_data` to `file_path`.
/// This vaguely represents Lodestone and designed to visually check your character data.
pub fn create_character_html(char_data: &CharacterData) -> String {
2024-09-29 17:45:53 -04:00
let mut env = Environment::new();
env.add_template(
"character.html",
include_str!("../templates/character.html"),
)
.unwrap();
let template = env.get_template("character.html").unwrap();
template
2024-09-29 17:45:53 -04:00
.render(context! {
name => char_data.name,
world => char_data.world,
data_center => char_data.data_center,
race => char_data.race,
subrace => char_data.tribe,
gender => char_data.gender,
2024-09-29 17:45:53 -04:00
nameday => char_data.nameday,
city_state => char_data.city_state
})
.unwrap()
2024-09-29 17:45:53 -04:00
}
/// Writes a visual HTML for `char_data` to `file_path`.
/// This vaguely represents Lodestone and designed to visually check your character data.
pub fn create_plate_html(char_data: &CharacterData) -> String {
let mut env = Environment::new();
2025-03-31 16:07:31 -04:00
env.add_template("plate.html", include_str!("../templates/plate.html"))
.unwrap();
let template = env.get_template("plate.html").unwrap();
template
.render(context! {
name => char_data.name,
world => char_data.world,
data_center => char_data.data_center,
title => char_data.plate_title,
level => char_data.plate_classjob_level,
class => char_data.plate_classjob,
search_comment => char_data.search_comment,
})
.unwrap()
}