Enum tpnote_lib::template::TemplateKind
source · #[non_exhaustive]
pub enum TemplateKind {
New,
FromClipboardYaml,
FromClipboard,
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
New
Templates used when Tp-Note is invoked with a directory path.
FromClipboardYaml
Templates used when the clipboard contains a text with a YAML header.
FromClipboard
Templates used when the clipboard contains a text without header.
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 (c.f. <Note>.render_content_to_html() and
<Note>.export_html()).
Implementations
sourceimpl TemplateKind
impl TemplateKind
sourcepub fn from<T: Content>(
path: &Path,
clipboard: &T,
stdin: &T
) -> (Self, Option<T>)
pub fn from<T: Content>(
path: &Path,
clipboard: &T,
stdin: &T
) -> (Self, Option<T>)
Constructor encoding the logic under what circumstances what template should be used.
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
sourceimpl Clone for TemplateKind
impl Clone for TemplateKind
sourcefn clone(&self) -> TemplateKind
fn clone(&self) -> TemplateKind
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresourceimpl Debug for TemplateKind
impl Debug for TemplateKind
sourceimpl Default for TemplateKind
impl Default for TemplateKind
sourcefn default() -> TemplateKind
fn default() -> TemplateKind
sourceimpl PartialEq<TemplateKind> for TemplateKind
impl PartialEq<TemplateKind> for TemplateKind
sourcefn eq(&self, other: &TemplateKind) -> bool
fn eq(&self, other: &TemplateKind) -> bool
impl Copy for TemplateKind
impl Eq for TemplateKind
impl StructuralEq for TemplateKind
impl StructuralPartialEq for TemplateKind
Auto Trait Implementations
impl RefUnwindSafe for TemplateKind
impl Send for TemplateKind
impl Sync for TemplateKind
impl Unpin for TemplateKind
impl UnwindSafe for TemplateKind
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.