MCPcopy
hub / github.com/hashicorp/hcl / IsStringLiteral

Method IsStringLiteral

hclsyntax/expression_template.go:140–146  ·  view source on GitHub ↗

IsStringLiteral returns true if and only if the template consists only of single string literal, as would be created for a simple quoted string like "foo". If this function returns true, then calling Value on the same expression with a nil EvalContext will return the literal value. Note that "${"f

()

Source from the content-addressed store, hash-verified

138// interpretation, not situations that result in literals as a technicality
139// of the template expression unwrapping behavior.
140func (e *TemplateExpr) IsStringLiteral() bool {
141 if len(e.Parts) != 1 {
142 return false
143 }
144 _, ok := e.Parts[0].(*LiteralValueExpr)
145 return ok
146}
147
148// TemplateJoinExpr is used to convert tuples of strings produced by template
149// constructs (i.e. for loops) into flat strings, by converting the values

Callers 2

Calls

no outgoing calls

Tested by 1