PR fixes
This commit is contained in:
@@ -49,6 +49,9 @@ _None_
|
||||
- Throw syntax error on empty variable tags (`{{ }}`) instead `fatalError`.
|
||||
[Ilya Puchka](https://github.com/ilyapuchka)
|
||||
[#263](https://github.com/stencilproject/Stencil/pull/263)
|
||||
- Fix for crashing range indexes when variable length is 1.
|
||||
[Łukasz Kuczborski](https://github.com/lkuczborski)
|
||||
[#306](https://github.com/stencilproject/Stencil/pull/306)
|
||||
|
||||
### Internal Changes
|
||||
|
||||
|
||||
@@ -48,10 +48,11 @@ public struct Variable: Equatable, Resolvable {
|
||||
|
||||
/// Resolve the variable in the given context
|
||||
public func resolve(_ context: Context) throws -> Any? {
|
||||
if (variable.hasPrefix("'") && variable.hasSuffix("'")) || (variable.hasPrefix("\"") && variable.hasSuffix("\"")) {
|
||||
if variable.count > 1 && (variable.hasPrefix("'") && variable.hasSuffix("'")) || (variable.hasPrefix("\"") && variable.hasSuffix("\"")) {
|
||||
// String literal
|
||||
guard variable.count > 1 else { return "" }
|
||||
return String(variable[variable.index(after: variable.startIndex) ..< variable.index(before: variable.endIndex)])
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Number literal
|
||||
|
||||
Reference in New Issue
Block a user