pub struct Engine { /* private fields */ }Expand description
A theme’s templates, compiled and ready to render.
Implementations§
Source§impl Engine
impl Engine
Sourcepub async fn build(db: &Db, code: &str) -> Result<Engine, ThemeError>
pub async fn build(db: &Db, code: &str) -> Result<Engine, ThemeError>
Compiles the theme code with its ancestors.
Sourcepub async fn build_with(
db: &Db,
code: &str,
configure: impl FnOnce(&mut Environment<'static>),
) -> Result<Engine, ThemeError>
pub async fn build_with( db: &Db, code: &str, configure: impl FnOnce(&mut Environment<'static>), ) -> Result<Engine, ThemeError>
Like Engine::build, with a hook that adds the application’s own
functions, filters and globals to the environment before the templates
compile.
Sourcepub fn stamp(&self) -> &str
pub fn stamp(&self) -> &str
Changes when the theme or an ancestor does; EngineCache compares it.
Sourcepub fn env(&self) -> &Environment<'static>
pub fn env(&self) -> &Environment<'static>
The environment, for a render path that needs more than Engine::render.
Sourcepub fn resolve(&self, path: &str) -> Option<(&str, Params)>
pub fn resolve(&self, path: &str) -> Option<(&str, Params)>
The page a request path resolves to, with its parameters.
Sourcepub fn page(&self, name: &str) -> Option<&PageSettings>
pub fn page(&self, name: &str) -> Option<&PageSettings>
A page’s settings by name (its path without the extension).
Sourcepub fn layout_settings(&self, path: &str) -> Option<&Value>
pub fn layout_settings(&self, path: &str) -> Option<&Value>
A layout’s settings bag by path.
Sourcepub fn page_bag(&self, name: &str) -> Option<&Value>
pub fn page_bag(&self, name: &str) -> Option<&Value>
A page’s whole settings bag by name, components included.
Sourcepub fn url_for(&self, name: &str, params: &Params) -> Option<String>
pub fn url_for(&self, name: &str, params: &Params) -> Option<String>
The URL of the page name with params.
Sourcepub fn routes(&self) -> &RouteTable
pub fn routes(&self) -> &RouteTable
The route table: every page’s pattern in matching order.
Sourcepub fn has(&self, kind: Kind, path: &str) -> bool
pub fn has(&self, kind: Kind, path: &str) -> bool
Whether the theme, or an ancestor, has this template.
Sourcepub fn render(
&self,
kind: Kind,
path: &str,
ctx: impl Serialize,
) -> Result<String, RenderError>
pub fn render( &self, kind: Kind, path: &str, ctx: impl Serialize, ) -> Result<String, RenderError>
Renders a template with ctx as its variables.
An error’s line as the author sees it, for a page the engine composed.
Auto Trait Implementations§
impl !Freeze for Engine
impl !RefUnwindSafe for Engine
impl !UnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more