-
-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template Enum support #1104
Comments
I'm not convinced. Why do you need this? Alternatively, could you do |
it would allow us to load different html files using a match statement without having to write something that clusters code. fn render_project_template(project: &str, high_res: bool) -> String {
match project {
"SamuConceptCharacter" => {
debug!("loaded: SamuConceptCharacter");
SamuConceptCharacter {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
"Saint-John" => {
debug!("loaded: Saint-John");
SaintJohn {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
"HomardRojas" => {
debug!("loaded: HomardRojas");
HomardRojas {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
"CarbonixWorkerSuit" => {
debug!("loaded: CarbonixWorkerSuit");
CarbonixWorkerSuit {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
"ClimbingExoSuit" => {
debug!("loaded: ClimbingExoSuit");
ClimbingExoSuit {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
"ClimbingExoSuit3d" => {
debug!("loaded: ClimbingExoSuit3d");
ClimbingExoSuit3d {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
"Intru" => {
debug!("loaded: Intru");
Intru {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
"TeamBlue" => {
debug!("loaded: TeamBlue");
TeamBlue {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
"TribalYellowDemon" => {
debug!("loaded: TribalYellowDemon");
TribalYellowDemon {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
"UrbanWhiteCrowMan" => {
debug!("loaded: UrbanWhiteCrowMan");
UrbanWhiteCrowMan {
project_name: project.into(),
high_res,
}
.render()
.unwrap()
}
_ => {
error!("loaded: MissingProject");
MissingProject {}.render().unwrap()
}
}
} Introducing enums instead would make it easier to organise espaclialy when declaring the templates |
So this runs into a bunch of issues where the enum media type must match each of the variant template's media type, which I think is tricky to enforce correctly. I think you could do this with newtype variants for a bunch of template types and then having a simple manual |
There is prior discussion to this feature request in issue #666. |
I'd like to use Askama as follows:
Is this a possibility in the future?
The text was updated successfully, but these errors were encountered: