pub struct FrameworkTemplates { /* private fields */ }Expand description
Thread-safe framework template environment with hot reload support
Templates are loaded from XDG directories with embedded fallbacks. The environment supports atomic reload for development hot-reload.
Implementations§
Source§impl FrameworkTemplates
impl FrameworkTemplates
Sourcepub fn new() -> Result<Self, FrameworkTemplateError>
pub fn new() -> Result<Self, FrameworkTemplateError>
Create a new framework templates instance
Loads templates from XDG directories. Templates MUST exist on disk
(either in config or cache directory). Run acton-htmx templates init
to download them.
§Errors
Returns error if templates are not found or cannot be loaded.
Sourcepub fn get_config_dir() -> Option<PathBuf>
pub fn get_config_dir() -> Option<PathBuf>
Get the XDG config directory for framework templates
Returns $XDG_CONFIG_HOME/acton-htmx/templates/framework/ or
~/.config/acton-htmx/templates/framework/ if not set.
Sourcepub fn get_cache_dir() -> Option<PathBuf>
pub fn get_cache_dir() -> Option<PathBuf>
Get the XDG cache directory for framework templates
Returns $XDG_CACHE_HOME/acton-htmx/templates/framework/ or
~/.cache/acton-htmx/templates/framework/ if not set.
Sourcepub fn get_embedded_template(name: &str) -> Option<&'static str>
pub fn get_embedded_template(name: &str) -> Option<&'static str>
Get embedded template content (for CLI to write to cache)
This is used by the CLI templates init command to populate the cache.
Sourcepub fn embedded_template_names() -> impl Iterator<Item = &'static str>
pub fn embedded_template_names() -> impl Iterator<Item = &'static str>
Get all embedded template names
Sourcepub fn render(
&self,
name: &str,
ctx: Value,
) -> Result<String, FrameworkTemplateError>
pub fn render( &self, name: &str, ctx: Value, ) -> Result<String, FrameworkTemplateError>
Render a template with the given context
§Errors
Returns error if the template is not found or rendering fails.
Sourcepub fn render_with_map(
&self,
name: &str,
ctx: HashMap<&str, Value>,
) -> Result<String, FrameworkTemplateError>
pub fn render_with_map( &self, name: &str, ctx: HashMap<&str, Value>, ) -> Result<String, FrameworkTemplateError>
Render a template with a context map
Convenience method that accepts a HashMap instead of minijinja::Value.
§Errors
Returns error if the template is not found or rendering fails.
Sourcepub fn reload(&self) -> Result<(), FrameworkTemplateError>
pub fn reload(&self) -> Result<(), FrameworkTemplateError>
Reload all templates from disk
Useful for hot-reload during development. Creates a new environment and atomically swaps it with the current one.
§Errors
Returns error if templates cannot be reloaded.
Sourcepub fn is_customized(&self, name: &str) -> bool
pub fn is_customized(&self, name: &str) -> bool
Check if a template exists in user config (customized)
Sourcepub fn get_template_path(&self, name: &str) -> Option<PathBuf>
pub fn get_template_path(&self, name: &str) -> Option<PathBuf>
Get the path where a template would be loaded from
Returns the actual file path if found on disk, or None if using embedded.
Sourcepub const fn config_dir(&self) -> Option<&PathBuf>
pub const fn config_dir(&self) -> Option<&PathBuf>
Get a reference to the config directory
Trait Implementations§
Source§impl Clone for FrameworkTemplates
impl Clone for FrameworkTemplates
Source§impl Debug for FrameworkTemplates
impl Debug for FrameworkTemplates
Auto Trait Implementations§
impl Freeze for FrameworkTemplates
impl !RefUnwindSafe for FrameworkTemplates
impl Send for FrameworkTemplates
impl Sync for FrameworkTemplates
impl Unpin for FrameworkTemplates
impl !UnwindSafe for FrameworkTemplates
Blanket Implementations§
Source§impl<T> ActonMessage for T
impl<T> ActonMessage for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().