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
()
| 138 | // interpretation, not situations that result in literals as a technicality |
| 139 | // of the template expression unwrapping behavior. |
| 140 | func (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 |
no outgoing calls