All the template are now compiled at compile-time with the `ructe` crate.
I preferred to use it instead of askama because it allows more complex Rust expressions, where askama only supports a small subset of expressions and doesn't allow them everywhere (for instance, `{{ macro!() | filter }}` would result in a parsing error).
The diff is quite huge, but there is normally no changes in functionality.
Fixes #161 and unblocks #110 and #273
		
	
			
		
			
				
	
	
		
			31 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| @use templates::base;
 | |
| @use template_utils::*;
 | |
| @use routes::user::UpdateUserForm;
 | |
| @use validator::ValidationErrors;
 | |
| 
 | |
| @(ctx: BaseContext, form: UpdateUserForm, errors: ValidationErrors)
 | |
| 
 | |
| @:base(ctx, "Edit your account", {}, {}, {
 | |
|     <h1>@i18n!(ctx.1, "Your Profile")</h1>
 | |
|     <form method="post">
 | |
|         <!-- Rocket hack to use various HTTP methods -->
 | |
|         <input type=hidden name="_method" value="put">
 | |
| 
 | |
|         @input!(ctx.1, display_name (text), "Display name", form, errors.clone())
 | |
|         @input!(ctx.1, email (text), "Email", form, errors.clone())
 | |
|         @input!(ctx.1, summary (text), "Summary", form, errors)
 | |
| 
 | |
|         <input type="submit" value="@i18n!(ctx.1, "Update account")"/>
 | |
|     </form>
 | |
| 
 | |
|     <h2>@i18n!(ctx.1, "Danger zone")</h2>
 | |
|     <p>@i18n!(ctx.1, "Be very careful, any action taken here can't be cancelled.")
 | |
|     @if !ctx.2.clone().expect("Editing profile while not connected").is_admin {
 | |
|         <form method="post" action="/@@/@ctx.2.clone().expect("Editing profile while not connected").get_fqn(ctx.0)/delete">
 | |
|             <input type="submit" class="inline-block button destructive" value="@i18n!(ctx.1, "Delete your account")">
 | |
|         </form>
 | |
|     } else {
 | |
|         <p>@i18n!(ctx.1, "Sorry, but as an admin, you can't leave your instance.")</p>
 | |
|     }
 | |
| })
 |