Skip to content

Commit

Permalink
sync templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jondot committed Nov 10, 2024
1 parent 8949328 commit dada9fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion loco-new/base_template/migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub struct Migrator;
impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![
// inject-below
Box::new(m20220101_000001_users::Migration),
// inject-above (do not remove this comment)
]
}
}
9 changes: 9 additions & 0 deletions loco-new/base_template/src/initializers/view_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ impl Initializer for ViewEngineInitializer {
}

async fn after_routes(&self, router: AxumRouter, _ctx: &AppContext) -> Result<AxumRouter> {
#[allow(unused_mut)]
let mut tera_engine = engines::TeraView::build()?;
if std::path::Path::new(I18N_DIR).exists() {
let arc = ArcLoader::builder(&I18N_DIR, unic_langid::langid!("en-US"))
.shared_resources(Some(&[I18N_SHARED.into()]))
.customize(|bundle| bundle.set_use_isolating(false))
.build()
.map_err(|e| Error::string(&e.to_string()))?;
#[cfg(debug_assertions)]
tera_engine
.tera
.lock()
.expect("lock")
.register_function("t", FluentLoader::new(arc));

#[cfg(not(debug_assertions))]
tera_engine
.tera
.register_function("t", FluentLoader::new(arc));
Expand Down

0 comments on commit dada9fa

Please sign in to comment.