This commit is contained in:
Ondrej Vlach 2023-11-26 18:45:50 +01:00
parent b65b1a7a54
commit ab3dbaf0fa
3 changed files with 11 additions and 3 deletions

View File

@ -4,7 +4,7 @@ use std::collections::HashMap;
use rocket::{*, fairing::AdHoc};
use rocket_dyn_templates::{Template, tera::Value};
use ::serde::Deserialize;
use tools::tera::static_filter;
use tools::tera::{static_filter, translate_filter};
pub mod routes;
pub mod services;
@ -31,6 +31,7 @@ pub fn rocket_builder() -> Rocket<Build> {
rocket.attach(
Template::try_custom(|engines| {
engines.tera.register_filter("static", static_filter);
engines.tera.register_filter("translate", translate_filter);
Ok(())
})
).attach(

View File

@ -10,3 +10,10 @@ pub fn static_filter(
let host = args.get("static_host");
return Ok(rocket_dyn_templates::tera::Value::String(format!("{}/{}", host.unwrap().as_str().unwrap(), value.as_str().unwrap()))); // TODO: fix-me here!
}
pub fn translate_filter(
value: &Value,
args: &HashMap<String, rocket_dyn_templates::tera::Value>
) -> Result<Value, Error> {
return Ok(rocket_dyn_templates::tera::Value::String(format!("{}", value.as_str().unwrap()))); // TODO: fix-me here!
}

View File

@ -12,8 +12,8 @@
<div class="avatar p-1"><img class="img-thumbnail shadow-2-strong" src="images/avatar.jpg" width="160" height="160"/></div>
<div class="header-bio mt-3">
<div data-aos="zoom-in" data-aos-delay="0">
<h2 class="h1">Walter Patterson</h2>
<p>Front-end Developer and Graphic Designer</p>
<h2 class="h1"> {{ cv.person.name }} {{ cv.person.surname }} </h2>
<p>{{ "Frontend and web developer" | translate }}</p>
</div>
<div class="header-social mb-3 d-print-none" data-aos="zoom-in" data-aos-delay="200">
<nav role="navigation">