Disable the now tag on Linux

NSDate is unavailable
This commit is contained in:
Kyle Fuller
2016-02-11 19:31:39 -05:00
parent 6deb93ac19
commit 3ec009381d
4 changed files with 15 additions and 2 deletions

View File

@@ -13,7 +13,9 @@ public class Namespace {
registerTag("for", parser: ForNode.parse)
registerTag("if", parser: IfNode.parse)
registerTag("ifnot", parser: IfNode.parse_ifnot)
#if !os(Linux)
registerTag("now", parser: NowNode.parse)
#endif
registerTag("include", parser: IncludeNode.parse)
registerTag("extends", parser: ExtendsNode.parse)
registerTag("block", parser: BlockNode.parse)

View File

@@ -76,6 +76,8 @@ public class VariableNode : NodeType {
}
}
#if !os(Linux)
public class NowNode : NodeType {
public let format:Variable
@@ -114,6 +116,8 @@ public class NowNode : NodeType {
return formatter!.stringFromDate(date)
}
}
#endif
public class ForNode : NodeType {
let variable:Variable

View File

@@ -4,6 +4,7 @@ import Stencil
func testNowNode() {
#if !os(Linux)
describe("NowNode") {
$0.describe("parsing") {
$0.it("parses default format without any now arguments") {
@@ -38,4 +39,5 @@ func testNowNode() {
}
}
}
#endif
}

View File

@@ -38,9 +38,14 @@ func testTokenParser() {
}
$0.it("can parse a tag token") {
let namespace = Namespace()
namespace.registerSimpleTag("known") { _ in
return ""
}
let parser = TokenParser(tokens: [
Token.Block(value: "now"),
], namespace: Namespace())
Token.Block(value: "known"),
], namespace: namespace)
let nodes = try parser.parse()
try expect(nodes.count) == 1