use askama::Template;
use axum::{Router, response::Html, routing::get};
use ocre::{Ctx, Result, render};
<% if auth %>
use crate::auth::CurrentUser;
<% endif %>
pub fn routes() -> Router<Ctx> {
Router::new()
<% for action in actions %>
.route("<%= action.path %>", get(<%= action.name %>))
<% endfor %>
}
#[allow(dead_code)]
pub mod paths {
<% for action in actions %>
pub fn <%= action.name %>() -> &'static str {
"<%= action.path %>"
}
<% if not loop.last %>
<% endif %>
<% endfor %>
}
<% for action in actions %>
#[derive(Template)]
#[template(path = "<%= module %>/<%= action.name %>.html")]
struct <%= action.pascal %>View;
<% if auth %>
async fn <%= action.name %>(CurrentUser(_user): CurrentUser) -> Result<Html<String>> {
<% else %>
async fn <%= action.name %>() -> Result<Html<String>> {
<% endif %>
render(&<%= action.pascal %>View)
}
<% endfor %>