pub struct WindowTemplate {
pub content: String,
pub kind: TemplateKind,
}Expand description
A window file template with placeholder replacement.
Fields§
§content: StringTemplate content with placeholders
kind: TemplateKindTemplate type
Implementations§
Source§impl WindowTemplate
impl WindowTemplate
Sourcepub fn load(kind: TemplateKind) -> Self
pub fn load(kind: TemplateKind) -> Self
Load a template from embedded resources.
§Examples
use dampen_cli::commands::add::templates::{WindowTemplate, TemplateKind};
let template = WindowTemplate::load(TemplateKind::RustModule);
assert!(!template.content.is_empty());Sourcepub fn render(&self, window_name: &WindowNameVariants) -> String
pub fn render(&self, window_name: &WindowNameVariants) -> String
Render the template by replacing placeholders with actual values.
§Placeholders
{{WINDOW_NAME}}- replaced with snake_case name{{WINDOW_NAME_PASCAL}}- replaced with PascalCase name{{WINDOW_NAME_TITLE}}- replaced with Title Case name
§Examples
use dampen_cli::commands::add::templates::{WindowTemplate, TemplateKind, WindowNameVariants};
let template = WindowTemplate::load(TemplateKind::RustModule);
let names = WindowNameVariants {
snake: "user_profile".to_string(),
pascal: "UserProfile".to_string(),
title: "User Profile".to_string(),
};
let rendered = template.render(&names);
assert!(rendered.contains("user_profile"));Trait Implementations§
Source§impl Clone for WindowTemplate
impl Clone for WindowTemplate
Source§fn clone(&self) -> WindowTemplate
fn clone(&self) -> WindowTemplate
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WindowTemplate
impl RefUnwindSafe for WindowTemplate
impl Send for WindowTemplate
impl Sync for WindowTemplate
impl Unpin for WindowTemplate
impl UnwindSafe for WindowTemplate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more