pub struct TemplatePlugin { /* private fields */ }Expand description
Plugin that post-processes compiled HTML through templates.
Runs in the after_compile phase. For each HTML file in site_dir:
- Reads the companion
.meta.jsonsidecar (from frontmatter extraction) - Determines the layout from frontmatter (
layoutfield, default:page) - Renders the HTML through the template chain
- Writes the rendered result back to the same file
Falls back gracefully if no templates directory exists.
Implementations§
Source§impl TemplatePlugin
impl TemplatePlugin
Sourcepub const fn new(config: TemplateConfig) -> Self
pub const fn new(config: TemplateConfig) -> Self
Creates a new TemplatePlugin with the given configuration.
§Examples
use ssg::plugin::Plugin;
use ssg::template_engine::TemplateConfig;
use ssg::template_plugin::TemplatePlugin;
let p = TemplatePlugin::new(TemplateConfig::default());
assert_eq!(p.name(), "templates");Sourcepub fn from_template_dir(template_dir: &Path) -> Self
pub fn from_template_dir(template_dir: &Path) -> Self
Creates a TemplatePlugin that looks for templates in the standard
templates/tera/ subdirectory of the template dir.
§Examples
use ssg::plugin::Plugin;
use ssg::template_plugin::TemplatePlugin;
use std::path::Path;
let p = TemplatePlugin::from_template_dir(Path::new("templates"));
assert_eq!(p.name(), "templates");Trait Implementations§
Source§impl Debug for TemplatePlugin
impl Debug for TemplatePlugin
Source§impl Plugin for TemplatePlugin
Available on crate feature templates only.
impl Plugin for TemplatePlugin
Available on crate feature
templates only.Source§fn before_compile(&self, ctx: &PluginContext) -> Result<(), SsgError>
fn before_compile(&self, ctx: &PluginContext) -> Result<(), SsgError>
Called before site compilation begins. Read more
Source§fn after_compile(&self, ctx: &PluginContext) -> Result<(), SsgError>
fn after_compile(&self, ctx: &PluginContext) -> Result<(), SsgError>
Called after site compilation completes. Read more
Source§fn transform_html(
&self,
html: &str,
_path: &Path,
_ctx: &PluginContext,
) -> Result<String, SsgError>
fn transform_html( &self, html: &str, _path: &Path, _ctx: &PluginContext, ) -> Result<String, SsgError>
Per-file HTML transform hook — called once per HTML file during
the fused transform pass. Read more
Source§fn has_transform(&self) -> bool
fn has_transform(&self) -> bool
Returns
true if this plugin implements transform_html.
Override to true to opt in to the fused transform pass.Source§fn needs_all_files(&self) -> bool
fn needs_all_files(&self) -> bool
Returns
true if this plugin must always observe the full
cache.html_files() list — even during --incremental
rebuilds that only invalidated a handful of pages. Read moreAuto Trait Implementations§
impl Freeze for TemplatePlugin
impl RefUnwindSafe for TemplatePlugin
impl Send for TemplatePlugin
impl Sync for TemplatePlugin
impl Unpin for TemplatePlugin
impl UnsafeUnpin for TemplatePlugin
impl UnwindSafe for TemplatePlugin
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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 more