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: ExpressionThe condition expression.
true_template: TemplateThe 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: StripModeThe whitespace strip mode to use on the template elements preceeding and following after
the if expression.
else_strip: StripModeThe 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: StripModeThe whitespace strip mode to use on the template elements preceeding and following after
the endif marker of this directive.
Implementations
sourceimpl IfDirective
impl IfDirective
sourcepub fn new<T>(cond_expr: T, true_template: Template) -> IfDirectivewhere
T: Into<Expression>,
pub fn new<T>(cond_expr: T, true_template: Template) -> IfDirectivewhere
T: Into<Expression>,
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.
sourcepub fn with_false_template<T>(self, else_template: T) -> IfDirectivewhere
T: Into<Template>,
pub fn with_false_template<T>(self, else_template: T) -> IfDirectivewhere
T: Into<Template>,
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.
sourcepub fn with_if_strip(self, strip: StripMode) -> IfDirective
pub fn with_if_strip(self, strip: StripMode) -> IfDirective
Sets the whitespace strip mode to use on the template elements preceeding and following
after the if expression and returns the modified IfDirective.
sourcepub fn with_else_strip(self, strip: StripMode) -> IfDirective
pub fn with_else_strip(self, strip: StripMode) -> IfDirective
Sets the whitespace strip mode to use on the template elements preceeding and following
after the else expression and returns the modified IfDirective.
sourcepub fn with_endif_strip(self, strip: StripMode) -> IfDirective
pub fn with_endif_strip(self, strip: StripMode) -> 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
sourceimpl Clone for IfDirective
impl Clone for IfDirective
sourcefn clone(&self) -> IfDirective
fn clone(&self) -> IfDirective
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresourceimpl Debug for IfDirective
impl Debug for IfDirective
sourceimpl Format for IfDirective
impl Format for IfDirective
sourceimpl From<IfDirective> for Directive
impl From<IfDirective> for Directive
sourcefn from(directive: IfDirective) -> Self
fn from(directive: IfDirective) -> Self
sourceimpl PartialEq<IfDirective> for IfDirective
impl PartialEq<IfDirective> for IfDirective
sourcefn eq(&self, other: &IfDirective) -> bool
fn eq(&self, other: &IfDirective) -> bool
impl Eq for IfDirective
impl StructuralEq for IfDirective
impl StructuralPartialEq for IfDirective
Auto Trait Implementations
impl RefUnwindSafe for IfDirective
impl Send for IfDirective
impl Sync for IfDirective
impl Unpin for IfDirective
impl UnwindSafe for IfDirective
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.