pub struct NamesRender {
pub book: String,
pub annotations: HashMap<String, AnnotationNameAttributes>,
pub directory: String,
}Expand description
A struct representing the rendered template strings for all the output file and directory names for a given template.
This is used to (1) name files and directories when rendering templates to disk and (2) is included in the template’s context so that files/direcories related to the template can be references within the tenplate.
See Renderer::render() for more information.
Fields§
§book: StringThe output filename for a template with ContextMode::Book.
annotations: HashMap<String, AnnotationNameAttributes>The output filenames for a template with ContextMode::Annotation.
Internally this field is stored as a HashMap but is converted into a Vec before it’s
injected into a template.
directory: StringThe directory name for a template with StructureMode::Nested or
StructureMode::NestedGrouped.
Implementations§
Source§impl NamesRender
impl NamesRender
Sourcepub fn new(entry: &EntryContext<'_>, template: &Template) -> Result<Self>
pub fn new(entry: &EntryContext<'_>, template: &Template) -> Result<Self>
Creates a new instance of NamesRender.
Note that all names are generated regardless of the template’s ContextMode.
For example, when a separate template is used to render a Book and another for its
Annotations, it’s important that both templates have access to the other’s
filenames so they can link to one another if the user desires.
§Arguments
entry- The context injected into the filename templates.template- The template containing the filename templates.
§Errors
Will return Err if any templates have syntax errors or are referencing non-existent fields
in their respective contexts.
Sourcepub fn get_annotation_filename(&self, annotation_id: &str) -> String
pub fn get_annotation_filename(&self, annotation_id: &str) -> String
Returns the rendered annotation filename based on its id.
§Arguments
annotation_id- The annotation’s id.
Trait Implementations§
Source§impl Clone for NamesRender
impl Clone for NamesRender
Source§fn clone(&self) -> NamesRender
fn clone(&self) -> NamesRender
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NamesRender
impl Debug for NamesRender
Source§impl Default for NamesRender
impl Default for NamesRender
Source§fn default() -> NamesRender
fn default() -> NamesRender
Auto Trait Implementations§
impl Freeze for NamesRender
impl RefUnwindSafe for NamesRender
impl Send for NamesRender
impl Sync for NamesRender
impl Unpin for NamesRender
impl UnwindSafe for NamesRender
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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