Struct hcl::template::IfDirective

source ·
pub struct IfDirective {
    pub cond_expr: Expression,
    pub true_template: Template,
    pub false_template: Option<Template>,
    pub if_strip: StripMode,
    pub else_strip: StripMode,
    pub endif_strip: StripMode,
}
Expand description

The template if directive is the template equivalent of the conditional expression, allowing selection of one of two sub-templates based on the condition result.

Fields

cond_expr: Expression

The condition expression.

true_template: Template

The template that is included in the result string if the conditional expression evaluates to true.

false_template: Option<Template>

The template that is included in the result string if the if branch’s conditional expression evaluates to false. This is None if there is no else branch in which case the result string will be empty.

if_strip: StripMode

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

else_strip: StripMode

The whitespace strip mode to use on the template elements preceeding and following after the else expression. This has no effect if false_template is None.

endif_strip: StripMode

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

Implementations

Creates a new IfDirective from a conditional expression and a template that is included in the result string if the conditional expression evaluates to true.

Adds a template for the else branch which is included in the result string if the condition of the IfDirective evaluates to false and returns the modified IfDirective.

Sets the whitespace strip mode to use on the template elements preceeding and following after the if expression and returns the modified IfDirective.

Sets the whitespace strip mode to use on the template elements preceeding and following after the else expression and returns the modified IfDirective.

Sets the whitespace strip mode to use on the template elements preceeding and following after the endif marker of this directive and returns the modified IfDirective.

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
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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.