-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for the tera templating engine
- Use the tera templating engine for rendering inital page loads - Use the `in-vite` crate to implement the required integration with vite rather than the internal implementation. - Implement default initializer to be used with loco apps
- Loading branch information
Showing
11 changed files
with
4,563 additions
and
1,076 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//! Default Loco Initializer provided for adding InertiaJS rendering to Loco apps | ||
//! | ||
//! If modifications are needed to the behavior of the initializer a custom initializer | ||
//! can be implemented in your Loco app directly. | ||
use crate::InertiaConfigBuilder; | ||
use axum::{async_trait, Extension, Router as AxumRouter}; | ||
use loco_rs::{ | ||
app::{AppContext, Initializer}, | ||
Error, Result, | ||
}; | ||
use tracing::debug; | ||
|
||
pub struct InertiaInitializer; | ||
|
||
#[async_trait] | ||
impl Initializer for InertiaInitializer { | ||
fn name(&self) -> String { | ||
"inertia".to_string() | ||
} | ||
|
||
/// Creates a new [InertiaConfig] instance based on the [AppContext] environment and adds | ||
/// it to the router as a layer [Extension] | ||
async fn after_routes(&self, router: AxumRouter, ctx: &AppContext) -> Result<AxumRouter> { | ||
debug!("Initializing..."); | ||
|
||
let inertia_config = InertiaConfigBuilder::new(ctx.environment.clone()) | ||
.build() | ||
.map_err(|err| Error::Message(err.to_string()))?; | ||
|
||
Ok(router.layer(Extension(inertia_config))) | ||
} | ||
} |
Oops, something went wrong.