Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abae80d39d | ||
|
|
d024da5567 |
@@ -1,5 +1,13 @@
|
||||
# Stencil Changelog
|
||||
|
||||
## 0.7.1
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fixes an issue where using `{% if %}` statements which use operators would
|
||||
throw a syntax error.
|
||||
|
||||
|
||||
## 0.7.0
|
||||
|
||||
### Breaking
|
||||
|
||||
@@ -167,9 +167,6 @@ class IfNode : NodeType {
|
||||
|
||||
class func parse(_ parser: TokenParser, token: Token) throws -> NodeType {
|
||||
var components = token.components()
|
||||
guard components.count == 2 else {
|
||||
throw TemplateSyntaxError("'if' statements should use the following 'if condition' `\(token.contents)`.")
|
||||
}
|
||||
components.removeFirst()
|
||||
var trueNodes = [NodeType]()
|
||||
var falseNodes = [NodeType]()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Stencil",
|
||||
"version": "0.7.0",
|
||||
"version": "0.7.1",
|
||||
"summary": "Stencil is a simple and powerful template language for Swift.",
|
||||
"homepage": "https://stencil.fuller.li",
|
||||
"license": {
|
||||
@@ -13,7 +13,7 @@
|
||||
"social_media_url": "https://twitter.com/kylefuller",
|
||||
"source": {
|
||||
"git": "https://github.com/kylef/Stencil.git",
|
||||
"tag": "0.6.0"
|
||||
"tag": "0.7.1"
|
||||
},
|
||||
"source_files": [
|
||||
"Sources/*.swift"
|
||||
|
||||
@@ -27,6 +27,28 @@ func testIfNode() {
|
||||
try expect(falseNode?.text) == "false"
|
||||
}
|
||||
|
||||
$0.it("can parse an if with complex expression") {
|
||||
let tokens: [Token] = [
|
||||
.block(value: "if value == \"test\" and not name"),
|
||||
.text(value: "true"),
|
||||
.block(value: "else"),
|
||||
.text(value: "false"),
|
||||
.block(value: "endif")
|
||||
]
|
||||
|
||||
let parser = TokenParser(tokens: tokens, namespace: Namespace())
|
||||
let nodes = try parser.parse()
|
||||
let node = nodes.first as? IfNode
|
||||
let trueNode = node?.trueNodes.first as? TextNode
|
||||
let falseNode = node?.falseNodes.first as? TextNode
|
||||
|
||||
try expect(nodes.count) == 1
|
||||
try expect(node?.trueNodes.count) == 1
|
||||
try expect(trueNode?.text) == "true"
|
||||
try expect(node?.falseNodes.count) == 1
|
||||
try expect(falseNode?.text) == "false"
|
||||
}
|
||||
|
||||
$0.it("can parse an ifnot block") {
|
||||
let tokens: [Token] = [
|
||||
.block(value: "ifnot value"),
|
||||
|
||||
Reference in New Issue
Block a user