pub struct ForDirective {
pub key_var: Option<Identifier>,
pub value_var: Identifier,
pub collection_expr: Expression,
pub template: Template,
pub for_strip: Strip,
pub endfor_strip: Strip,
}
Expand description
The template for
directive is the template equivalent of the for expression, producing zero
or more copies of its sub-template based on the elements of a collection.
Fields§
§key_var: Option<Identifier>
Optional iterator key variable identifier.
value_var: Identifier
The iterator value variable identifier.
collection_expr: Expression
The expression that produces the list or object of elements to iterate over.
template: Template
The template that is included in the result string for each loop iteration.
for_strip: Strip
The whitespace strip mode to use on the template elements preceeding and following after
the for
expression.
endfor_strip: Strip
The whitespace strip mode to use on the template elements preceeding and following after
the endfor
marker of this directive.
Implementations§
Source§impl ForDirective
impl ForDirective
Sourcepub fn new<T>(
value: Identifier,
collection_expr: T,
template: Template,
) -> ForDirectivewhere
T: Into<Expression>,
pub fn new<T>(
value: Identifier,
collection_expr: T,
template: Template,
) -> ForDirectivewhere
T: Into<Expression>,
Creates a new ForDirective
from the provided iterator value identifier, an expression
that produces the list or object of elements to iterate over, and the template the is
included in the result string for each loop iteration.
Sourcepub fn with_key_var(self, key_var: Identifier) -> ForDirective
pub fn with_key_var(self, key_var: Identifier) -> ForDirective
Adds the iterator key variable identifier to the for
expression and returns the modified
ForDirective
.
Sourcepub fn with_for_strip(self, strip: Strip) -> ForDirective
pub fn with_for_strip(self, strip: Strip) -> ForDirective
Sets the whitespace strip mode to use on the template elements preceeding and following
after the for
expression and returns the modified ForDirective
.
Sourcepub fn with_endfor_strip(self, strip: Strip) -> ForDirective
pub fn with_endfor_strip(self, strip: Strip) -> ForDirective
Sets the whitespace strip mode to use on the template elements preceeding and following
after the endfor
marker of this directive and returns the modified ForDirective
.
Trait Implementations§
Source§impl Clone for ForDirective
impl Clone for ForDirective
Source§fn clone(&self) -> ForDirective
fn clone(&self) -> ForDirective
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ForDirective
impl Debug for ForDirective
Source§impl Format for ForDirective
impl Format for ForDirective
Source§fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>where
W: Write,
fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>where
W: Write,
Source§impl From<ForDirective> for Directive
impl From<ForDirective> for Directive
Source§fn from(directive: ForDirective) -> Self
fn from(directive: ForDirective) -> Self
Source§impl From<ForDirective> for ForDirective
impl From<ForDirective> for ForDirective
Source§fn from(value: ForDirective) -> Self
fn from(value: ForDirective) -> Self
Source§impl From<ForDirective> for ForDirective
impl From<ForDirective> for ForDirective
Source§fn from(value: ForDirective) -> Self
fn from(value: ForDirective) -> Self
Source§impl PartialEq for ForDirective
impl PartialEq for ForDirective
impl Eq for ForDirective
impl StructuralPartialEq for ForDirective
Auto Trait Implementations§
impl Freeze for ForDirective
impl RefUnwindSafe for ForDirective
impl Send for ForDirective
impl Sync for ForDirective
impl Unpin for ForDirective
impl UnwindSafe for ForDirective
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.