#[non_exhaustive]pub enum TemplateKind {
FromDir,
FromTextFile,
AnnotateFile,
SyncFilename,
None,
}
Expand description
Each workflow is related to one TemplateKind
, which relates to one
content template and one filename template.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
FromDir
Templates used when Tp-Note is invoked with a directory path. Clipboard data may be available.
FromTextFile
Templates used when Tp-Note is invoked with a path pointing to a text file that does not contain a YAML header.
AnnotateFile
Templates used when Tp-Note is invoked with a path pointing to a non text file.
SyncFilename
Templates used when Tp-Note is invoked with a path pointing to a Tp-Note
text file with a valid YAML header (with a title:
field).
None
No templates are used, but the file is still parsed in order to
render it later to HTML (cf. <Note>.render_content_to_html()
.
Implementations§
Source§impl TemplateKind
impl TemplateKind
Sourcepub fn from<T: Content>(path: &Path) -> (Self, Option<T>)
pub fn from<T: Content>(path: &Path) -> (Self, Option<T>)
A constructor returning the tuple (template_kind, Some(content))
.
template_kind
is the result of the logic calculating under what
circumstances what template should be used.
If path
has a Tp-Note extension (e.g. .md
) and the file indicated by
path
could be opened and loaded from disk, Some(content)
contains
its content. Otherwise None
is returned.
Sourcepub fn get_content_template(&self) -> String
pub fn get_content_template(&self) -> String
Returns the content template string as it is defined in the configuration file.
Panics for TemplateKind::SyncFilename
and TemplateKind::None
.
Sourcepub fn get_content_template_name(&self) -> &str
pub fn get_content_template_name(&self) -> &str
Returns the content template variable name as it is used in the configuration file.
Sourcepub fn get_filename_template(&self) -> String
pub fn get_filename_template(&self) -> String
Returns the file template string as it is defined in the configuration file.
Panics for TemplateKind::None
.
Sourcepub fn get_filename_template_name(&self) -> &str
pub fn get_filename_template_name(&self) -> &str
Returns the content template variable name as it is used in the configuration file.
Trait Implementations§
Source§impl Clone for TemplateKind
impl Clone for TemplateKind
Source§fn clone(&self) -> TemplateKind
fn clone(&self) -> TemplateKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TemplateKind
impl Debug for TemplateKind
Source§impl Default for TemplateKind
impl Default for TemplateKind
Source§fn default() -> TemplateKind
fn default() -> TemplateKind
Source§impl PartialEq for TemplateKind
impl PartialEq for TemplateKind
impl Copy for TemplateKind
impl Eq for TemplateKind
impl StructuralPartialEq for TemplateKind
Auto Trait Implementations§
impl Freeze for TemplateKind
impl RefUnwindSafe for TemplateKind
impl Send for TemplateKind
impl Sync for TemplateKind
impl Unpin for TemplateKind
impl UnwindSafe for TemplateKind
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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