pub struct Syntax {
pub expr: (String, String),
pub block: BlockStyle,
pub text_prefix: Option<String>,
}Expand description
The configurable surface syntax of a template.
Fields§
§expr: (String, String)The interpolation delimiter pair, e.g. ({{, }}).
block: BlockStyleHow block directives are delimited.
text_prefix: Option<String>Optional line prefix that is stripped; content after it is emitted as text.
A physical line whose first non-whitespace characters equal this prefix has the leading whitespace and the prefix removed. The rest of the line (including a trailing newline) is ordinary template text and may contain interpolations.
When both this and a BlockStyle::Line prefix could match the same line, the longer
prefix wins. They must not be identical (see Syntax::validate).
Implementations§
Source§impl Syntax
impl Syntax
Sourcepub fn brackets() -> Self
pub fn brackets() -> Self
Bracket style: {{ expr }} interpolation and {% ... %} block directives.
Sourcepub fn validate(&self) -> Result<(), TemplateError>
pub fn validate(&self) -> Result<(), TemplateError>
Checks that this syntax configuration is internally consistent.
Currently rejects an empty text_prefix and a text_prefix identical to the block
line prefix.
Sourcepub fn with_frontmatter(&self, front: &str) -> Result<Self, TemplateError>
pub fn with_frontmatter(&self, front: &str) -> Result<Self, TemplateError>
Applies frontmatter key/value overrides onto a copy of this syntax.
Recognized keys (all optional; each may appear at most once):
expr: <open> <close>— interpolation delimiters.block: paired <open> <close>— paired block directives.block: line <prefix>— line directives.text_prefix: <prefix>— strip this line prefix; remainder is verbatim text.
Blank lines and lines whose first non-whitespace character is # are ignored
(comments). Keys present in front replace the corresponding fields of self;
omitted keys are left unchanged. Locations in returned errors are relative to front.
Trait Implementations§
impl Eq for Syntax
impl StructuralPartialEq for Syntax
Auto Trait Implementations§
impl Freeze for Syntax
impl RefUnwindSafe for Syntax
impl Send for Syntax
impl Sync for Syntax
impl Unpin for Syntax
impl UnsafeUnpin for Syntax
impl UnwindSafe for Syntax
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.