Struct hcl::template::ForDirective

source ·
pub struct ForDirective {
    pub key_var: Option<Identifier>,
    pub value_var: Identifier,
    pub collection_expr: Expression,
    pub template: Template,
    pub for_strip: StripMode,
    pub endfor_strip: StripMode,
}
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: StripMode

The whitespace strip mode to use on the template elements preceeding and following after the for expression.

§endfor_strip: StripMode

The whitespace strip mode to use on the template elements preceeding and following after the endfor marker of this directive.

Implementations§

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.

Adds the iterator key variable identifier to the for expression and returns the modified ForDirective.

Sets the whitespace strip mode to use on the template elements preceeding and following after the for expression and returns the modified 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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats a HCL structure using a formatter and writes the result to the provided writer. Read more
Formats a HCL structure using a formatter and returns the result as a Vec<u8>. Read more
Formats a HCL structure using a formatter and returns the result as a String. Read more
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.