pub struct Template { /* private fields */ }
Expand description
The main type to represent the HCL template sub-languange.
A template behaves like an expression that always returns a string value. The different elements of the template are evaluated and combined into a single string to return.
See the module level
documentation for usage examples.
Implementations
sourceimpl Template
impl Template
sourcepub fn from_expr(expr: &TemplateExpr) -> Result<Self>
pub fn from_expr(expr: &TemplateExpr) -> Result<Self>
Expands a raw template expression to a template.
Errors
Returns an error if the parsing of raw string templates fails or if the template expression contains string literals with invalid escape sequences.
sourcepub fn elements_mut(&mut self) -> &mut [Element]
pub fn elements_mut(&mut self) -> &mut [Element]
Returns a mutable reference to the template elements.
sourceimpl Template
impl Template
sourcepub fn add_element<T>(self, element: T) -> Templatewhere
T: Into<Element>,
pub fn add_element<T>(self, element: T) -> Templatewhere
T: Into<Element>,
Adds a template element (literal, interpolation or directive) to the template.
sourcepub fn add_literal<T>(self, literal: T) -> Templatewhere
T: Into<String>,
pub fn add_literal<T>(self, literal: T) -> Templatewhere
T: Into<String>,
Adds a literal to the template.
sourcepub fn add_interpolation<T>(self, interpolation: T) -> Templatewhere
T: Into<Interpolation>,
pub fn add_interpolation<T>(self, interpolation: T) -> Templatewhere
T: Into<Interpolation>,
Adds an interpolation to the template.
sourcepub fn add_directive<T>(self, directive: T) -> Templatewhere
T: Into<Directive>,
pub fn add_directive<T>(self, directive: T) -> Templatewhere
T: Into<Directive>,
Adds a directive to the template.
Trait Implementations
sourceimpl<T> FromIterator<T> for Templatewhere
T: Into<Element>,
impl<T> FromIterator<T> for Templatewhere
T: Into<Element>,
sourcefn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
impl Eq for Template
impl StructuralEq for Template
impl StructuralPartialEq for Template
Auto Trait Implementations
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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
Mutably borrows from an owned value. Read more
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
Compare self to
key
and return true
if they are equal.