- title: if-then-else, true context: { cond: true } template: | if cond then 1 else 2 output: 1 - title: if-then-else, false context: { cond: false } template: | if cond then 1 else 2 output: 2 - title: if-then in array, true context: { cond: true } template: | - 0 - if cond then 1 output: [0, 1] - title: if-then in array, false context: { cond: false } template: | - 0 - if cond then 1 output: [0] # missing else branch should return a delete-marker (null) - title: if-then in object, true context: { cond: true } template: | key: if cond then 1 k2: 3 output: { key: 1, k2: 3 } - title: if-then in object, false context: { cond: false } template: | key: if cond then 1 k2: 3 output: { k2: 3 } # missing else branch should return a delete-marker #- title: if -> delete-marker, true # context: { cond: true } # template: | # key: # if cond # k2: 3 # output: { k2: 3 } # missing then/else branches should return a delete-marker #- title: if -> delete-marker, false # context: { cond: false } # template: | # key: # if cond # k2: 3 # output: { k2: 3 } # missing then/else branches should return a delete-marker - title: if->then, then => eval, true context: { key: { b: 1 } } template: | if true then key output: { b: 1 } - title: if->else, else => eval, false context: { key: { b: 1 } } template: | if false else key output: { b: 1 } # - title: $if->then, then => ${}, true # context: { key: "one" } # template: { $if: "true", then: "${key}" } # output: "one" #- title: $if->else, else => ${}, false # context: { key: "one" } # template: { $if: "false", else: "${key}" } # output: "one" #- title: $if->then, then => object, true # context: { cond: true } # template: { $if: "cond", then: { key: "hello world" } } # output: { key: "hello world" } #- title: $if->else, else => object, false # context: { cond: false } # template: { $if: "cond", else: { key: "hello world" } } # output: { key: "hello world" } #- title: $if->then, then => object, $eval, true # context: { cond: true, key: "hello world" } # template: { $if: "cond", then: { key: { $eval: "key" } } } # output: { key: "hello world" } #- title: $if->else, else => object, $eval, false # context: { cond: false, key: "hello world" } # template: { $if: "cond", else: { key: { $eval: "key" } } } # output: { key: "hello world" } #- title: $if->then, then => object, interpolation, true # context: { cond: true, key: "world" } # template: { $if: "cond", then: { key: "hello ${key}" } } # output: { key: "hello world" } #- title: $if->else, else => object, interpolation, false # context: { cond: false, key: "world" } # template: { $if: "cond", else: { key: "hello ${key}" } } # output: { key: "hello world" } #- title: $if->then->else, empty string # context: { cond: "", key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: f #- title: $if->then->else, nonempty string # context: { cond: "stuff", key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: t #- title: $if->then->else, string "0" # once upon a time, this was false in PHP.. maybe still is # context: { cond: "0", key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: t #- title: $if->then->else, zero # context: { cond: 0, key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: f #- title: $if->then->else, one # context: { cond: 1, key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: t #- title: $if->then->else, null # context: { cond: null, key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: f #- title: $if->then->else, empty array # context: { cond: [], key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: f #- title: $if->then->else, nonempty array # context: { cond: [1, 2], key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: t #- title: $if->then->else, empty object # context: { cond: {}, key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: f #- title: $if->then->else, nonempty object # context: { cond: { a: 2 }, key: "world" } # template: { $if: "cond", then: "t", else: "f" } # output: t #- title: $if->then->else, function # context: {} # template: {$if: 'min', then: "t", else: "f"} # output: t #- title: $if->then evaluating to nothing at the top level is null # context: { cond: false } # template: { $if: "cond", then: "t" } # output: null #- title: $if-then-else with undefined properties # context: { cond: true } # template: { $if: "cond", then: 1, foo: "bar", else: 2, bing: "baz" } # error: # type: ParseError # message: "value error: unknown field `bing`, expected one of `$if`, `then`, `else`"