diff options
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go')
-rw-r--r-- | vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go index fa79e3d..ca3dae1 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go +++ b/vendor/github.com/hashicorp/hcl2/hcl/hclsyntax/expression_template.go | |||
@@ -89,6 +89,26 @@ func (e *TemplateExpr) StartRange() hcl.Range { | |||
89 | return e.Parts[0].StartRange() | 89 | return e.Parts[0].StartRange() |
90 | } | 90 | } |
91 | 91 | ||
92 | // IsStringLiteral returns true if and only if the template consists only of | ||
93 | // single string literal, as would be created for a simple quoted string like | ||
94 | // "foo". | ||
95 | // | ||
96 | // If this function returns true, then calling Value on the same expression | ||
97 | // with a nil EvalContext will return the literal value. | ||
98 | // | ||
99 | // Note that "${"foo"}", "${1}", etc aren't considered literal values for the | ||
100 | // purposes of this method, because the intent of this method is to identify | ||
101 | // situations where the user seems to be explicitly intending literal string | ||
102 | // interpretation, not situations that result in literals as a technicality | ||
103 | // of the template expression unwrapping behavior. | ||
104 | func (e *TemplateExpr) IsStringLiteral() bool { | ||
105 | if len(e.Parts) != 1 { | ||
106 | return false | ||
107 | } | ||
108 | _, ok := e.Parts[0].(*LiteralValueExpr) | ||
109 | return ok | ||
110 | } | ||
111 | |||
92 | // TemplateJoinExpr is used to convert tuples of strings produced by template | 112 | // TemplateJoinExpr is used to convert tuples of strings produced by template |
93 | // constructs (i.e. for loops) into flat strings, by converting the values | 113 | // constructs (i.e. for loops) into flat strings, by converting the values |
94 | // tos strings and joining them. This AST node is not used directly; it's | 114 | // tos strings and joining them. This AST node is not used directly; it's |