- name: Heading with an ID
code: |
# This is a test {% #asdf %}
expected:
- tag: h1
attributes:
id: asdf
children:
- 'This is a test '
- name: Ordered list
code: |
1. foo
2. bar
3. baz
expected:
- tag: ol
children:
- tag: li
children: [foo]
- tag: li
children: [bar]
- tag: li
children: [baz]
- name: Ordered list with start
code: |
2. foo
3. bar
4. baz
expected:
- tag: ol
attributes:
start: 2
children:
- tag: li
children: [foo]
- tag: li
children: [bar]
- tag: li
children: [baz]
- name: Heading with a class
code: |
# This is a test {% .asdf %}
expected:
- tag: h1
attributes:
className: asdf
children:
- 'This is a test '
- name: Heading with multiple classes
code: |
# This is a test {% .foo .bar %}
expected:
- tag: h1
attributes:
className: foo bar
children:
- 'This is a test '
- name: Tag with hash and array
config:
tags:
test: { render: foo, attributes: { foo: { render: true } } }
code: |
{% test foo={bar: [1, 2, 3]} %}
This is a test
{% /test %}
expected:
- tag: foo
attributes:
foo: { bar: [1, 2, 3] }
children:
- tag: p
children: [This is a test]
- name: Empty hash with comma fails
config:
tags:
test: { render: foo, attributes: { foo: { render: true } } }
code: |
{% test foo={,} /%}
expectedError: Expected "}", identifier, string, or whitespace but "," found.
- name: Empty array with comma fails
config:
tags:
test: { render: foo, attributes: { foo: { render: true } } }
code: |
{% test foo=[,] /%}
expectedError: Expected "[", "]", "{", boolean, identifier, null, number, string, variable, or whitespace but "," found.
- name: Array without commas should fail
config:
tags:
test: { render: foo, attributes: { foo: { render: true } } }
code: |
{% test foo=[1 2 3] /%}
expectedError: Expected ",", "]", or whitespace but "2" found.
- name: Hash with trailing comma
config:
tags:
test: { render: foo, attributes: { foo: { render: true } } }
code: |
{% test foo={i: 1, j: 2, k: 3,} /%}
expected:
- tag: foo
attributes:
foo: { i: 1, j: 2, k: 3 }
- name: Array with trailing comma
config:
tags:
test: { render: foo, attributes: { foo: { render: true } } }
code: |
{% test foo=[1, 2 , 3, ] /%}
expected:
- tag: foo
attributes:
foo: [1, 2, 3]
- name: Self-closing tag
config:
tags:
test: { render: foo }
code: |
{% test /%}
expected:
- tag: foo
- name: Undefined tag
code: |
{% test %}
This is a test
{% /test %}
validation: false
expected:
- tag: p
children: [This is a test]
- name: Self-closing tag
code: |
{% partial file="foo" %}
bar
{% /partial %}
validation: false
expected: [null]
- name: Content with inline code text
code: |
This is a `test`
expected:
- tag: p
children:
- 'This is a '
- tag: code
children:
- test
- name: Fenced code block with an annotation
code: |
```ruby {% #test %}
example
```
expected:
- tag: pre
attributes: { id: 'test', 'data-language': 'ruby' }
children: ["example\n"]
- name: Frontmatter
code: |
---
foo: bar
---
# Example
This is a test
expected:
- tag: h1
children: [Example]
- tag: p
children:
- This is a test
- name: Inline variable
config:
variables:
foo: 10
code: |
This is a test: {% $foo %}
expected:
- tag: p
children:
- 'This is a test: '
- 10
- name: Inline tag
config:
tags:
foo:
render: span
code: |
# Testing
This is a {% foo %}test{% /foo %}.
expected:
- tag: h1
children: [Testing]
- tag: p
children:
- 'This is a '
- tag: span
children: [test]
- '.'
- name: Standalone function
code: |
foo {% and(1, 2, 3) %}
expected:
- tag: p
children:
- 'foo '
- true
- name: Function as a tag attribute
config:
tags:
foo:
render: p
attributes:
bar: { type: Object, render: true }
code: |
{% foo bar=and(true, true, true) /%}
expected:
- tag: p
attributes:
bar: true
- name: Simple conditional
config:
variables:
foo: false
code: |
{% if $foo %}
This is a test
{% /if %}
expected: []
- name: Simple conditional with non-existent variable
code: |
{% if $foo %}
This is a test
{% /if %}
expected: []
- name: Conditional with else clause
config:
variables:
foo: false
code: |
{% if $foo %}
Condition is true
{% else /%}
Condition is false
{% /if %}
expected:
- tag: p
children:
- Condition is false
- name: Conditional with multiple else clauses
config:
variables:
foo: false
bar: false
code: |
{% if $foo %}
Condition foo is true
{% else $bar /%}
Condition bar is true
{% else /%}
No condition is true
{% /if %}
expected:
- tag: p
children:
- No condition is true
- name: Conditional with equals
config:
variables:
foo: test
code: |
{% if equals($foo, "test") %}
test
{% /if %}
expected:
- tag: p
children: [test]
- name: Conditional with equals and an and function
config:
variables:
foo: test
bar: true
code: |
{% if and(equals($foo, "test"), $bar) %}
test
{% /if %}
expected:
- tag: p
children: [test]
- name: Conditional with equals and an or function
config:
variables:
foo: test
bar: true
code: |
{% if or(equals($foo, "wrong"), $bar) %}
test
{% /if %}
expected:
- tag: p
children: [test]
- name: Conditional that fails
config:
variables:
foo: test
code: |
{% if equals($foo, "wrong") %}
test
{% /if %}
expected: []
- name: Conditional with equals and an and function that fails
config:
variables:
foo: test
bar: true
code: |
{% if and(equals($foo, "wrong"), $bar) %}
test
{% /if %}
expected: []
- name: Conditional with equals and an undefined variable
code: |
{% if equals($foo.bar, "test") %}
test
{% /if %}
expected: []
- name: False condition with a not statement
config:
variables:
foo: true
code: |
{% if not($foo) %}
Conditions are met
{% /if %}
expected: []
- name: True condition with a not statement
config:
variables:
foo: false
code: |
{% if not($foo) %}
Conditions are met
{% /if %}
expected:
- tag: p
children:
- Conditions are met
- name: False condition with a not statement and other booleans
config:
variables:
foo: true
bar: false
baz: true
code: |
{% if not(and($baz, or($foo, $bar))) %}
Conditions are met
{% /if %}
expected: []
- name: True condition with a not statement and other booleans
config:
variables:
foo: true
bar: false
baz: false
code: |
{% if not(and($baz, or($foo, $bar))) %}
Conditions are met
{% /if %}
expected:
- tag: p
children:
- Conditions are met
- name: Condition with multiple variables
config:
variables:
foo: true
bar: true
code: |
{% if and($foo, $bar) %}
Conditions are met
{% /if %}
expected:
- tag: p
children:
- Conditions are met
- name: Using the default function
code: |
{% if default($foo, true) %}
Conditions are met
{% /if %}
expected:
- tag: p
children:
- Conditions are met
- name: Rendering HTML content
renderer: html
code: |
This is a test
expected: '<article><p>This is a test</p></article>'
- name: Rendering HTML with an array attribute
renderer: html
config:
tags:
test:
render: test
attributes:
foo: { type: Array, render: true }
code: |
{% test foo=[1,2,3] %}
This is a test
{% /test %}
expected: |
<article><test foo="1,2,3"><p>This is a test</p></test></article>
- name: Rendering HTML with a class name
renderer: html
code: |
# This is a test {% .foo .bar %}
expected: |
<article><h1 class="foo bar">This is a test </h1></article>
- name: Ignoring tags in fenced code blocks
code: |
```javascript {% process=false %}
foo
{% bar %}
```
expected:
- tag: pre
attributes:
data-language: javascript
children:
- "foo\n{% bar %}\n"
- name: Using a backtick in a fenced code block string attribute
config:
nodes:
fence:
render: pre
attributes:
content:
type: String
render: false
required: true
language:
type: String
render: 'data-language'
process:
type: Boolean
render: false
default: true
title:
type: String
code: |
~~~yaml {% title="this is a `test`" %}
example
~~~
expected:
- tag: pre
attributes:
data-language: yaml
title: 'this is a `test`'
children:
- "example\n"
- name: Conditional and variable in code example
config:
variables:
foo: bar
baz: true
code: |
```javascript {% process=true %}
testing
{% if $baz %}
console.log('This is a test: {% $foo %}');
{% /if %}
test
```
expected:
- tag: pre
attributes:
data-language: javascript
children:
- testing
- "\nconsole.log('This is a test: "
- 'bar'
- "');"
- "\ntest\n"
- name: Conditional and variable in code example with indentation
config:
variables:
foo: bar
baz: true
code: |
```javascript
function test() {
testing();
{% if $baz %}
console.log('This is a test: {% $foo %}');
{% /if %}
return;
}
```
expected:
- tag: pre
attributes:
data-language: javascript
children:
- "function test() {\n testing();"
- "\n console.log('This is a test: "
- 'bar'
- "');"
- "\n return;\n}\n"
- name: Conditional and variable in code example
config:
variables:
foo: bar
baz: false
code: |
```javascript {% process=true %}
testing
{% if $baz %}
console.log('This is a test: {% $foo %}');
{% /if %}
test
```
expected:
- tag: pre
attributes:
data-language: javascript
children:
- testing
- "\ntest\n"
- name: Tag after a comment in a code example
config:
tags:
test: { render: test }
code: |
```
# Testing
{% test /%}
test
```
expected:
- tag: pre
children:
- "# Testing\n"
- tag: test
- "\ntest\n"
- name: Multiple sequential tags in a code example
config:
tags:
test: { render: test }
code: |
```
{% test /%}
{% test /%}
{% test /%}
```
expected:
- tag: pre
children:
- tag: test
- "\n"
- tag: test
- "\n"
- tag: test
- "\n"
- name: Conditional and variable in the same line in a code example
config:
variables:
foo: bar
baz: true
code: |
```javascript {% process=true %}
testing {% $foo %} test{% if $baz %}example{% /if %} another test
```
expected:
- tag: pre
attributes:
data-language: javascript
children:
- 'testing '
- 'bar'
- ' test'
- 'example'
- " another test\n"
- name: Arbitrary tag in a code example
config:
tags:
test: { render: foo, attributes: { foo: { render: true } } }
code: |
```javascript {% process=true %}
testing
{% test foo="bar" %}
This is a test
{% /test %}
```
expected:
- tag: pre
attributes:
data-language: javascript
children:
- testing
- tag: foo
attributes:
foo: bar
children:
- "\nThis is a test"
- "\n"
- name: Nested variable inside of a tag in a code example
config:
tags:
token: { render: token }
variables:
foo: bar
baz: true
code: |
```javascript {% process=true %}
var stripe = Stripe('{% token %}{% $foo %}{% /token %}');
```
expected:
- tag: pre
attributes:
data-language: javascript
children:
- "var stripe = Stripe('"
- tag: token
children: [bar]
- "');\n"
- name: Handling for softbreaks
code: |
this is a test
with softbreaks
expected:
- tag: p
children:
- this is a test
- ' '
- with softbreaks
- name: Nested variable access with a string
config:
variables:
foo:
this is a test: bar
code: |
this is a test: {% $foo["this is a test"] %}
expected:
- tag: p
children:
- 'this is a test: '
- bar
- name: Disabled setext heading
code: |
Testing
-------
expected:
- tag: p
children: [Testing]
- tag: hr
- name: Advanced table format
code: |
{% table %}
* Test 1 - 1 {% width="20%" %}
* Test 1 - 2
* Test 1 - 3
---
* Test 2 - 1
* Test 2 - 2 {% colspan=2 %}
* Test 2 - 3
---
* Test 3 - 1
* Test 3 - 2
* Test 3 - 3
{% /table %}
expected:
- tag: table
children:
- tag: thead
children:
- tag: tr
children:
- tag: th
attributes:
width: 20%
children: ['Test 1 - 1 ']
- tag: th
children: [Test 1 - 2]
- tag: th
children: [Test 1 - 3]
- tag: tbody
children:
- tag: tr
children:
- tag: td
children: [Test 2 - 1]
- tag: td
children: ['Test 2 - 2 ']
attributes:
colSpan: 2
- tag: td
children: [Test 2 - 3]
- tag: tr
children:
- tag: td
children: [Test 3 - 1]
- tag: td
children: [Test 3 - 2]
- tag: td
children: [Test 3 - 3]
- name: Advanced table without header
code: |
{% table %}
---
* foo
* bar
{% /table %}
expected:
- tag: table
children:
- tag: thead
- tag: tbody
children:
- tag: tr
children:
- tag: td
children: [foo]
- tag: td
children: [bar]
- name: Advanced table with conditional row
config:
variables:
foo: false
bar: true
code: |
{% table %}
* Test 1 - 1
* Test 1 - 2
* Test 1 - 3
---
{% if $foo %}
* Test 2 - 1
* Test 2 - 2
* Test 2 - 3
{% /if %}
---
{% if $bar %}
* Test 3 - 1
* Test 3 - 2
* Test 3 - 3
{% /if %}
{% /table %}
expected:
- tag: table
children:
- tag: thead
children:
- tag: tr
children:
- tag: th
children: ['Test 1 - 1']
- tag: th
children: [Test 1 - 2]
- tag: th
children: [Test 1 - 3]
- tag: tbody
children:
- tag: tr
children:
- tag: td
children: [Test 3 - 1]
- tag: td
children: [Test 3 - 2]
- tag: td
children: [Test 3 - 3]
- name: Advanced table with multiple conditional rows
config:
variables:
foo: true
code: |
{% table %}
* Test 1 - 1
* Test 1 - 2
* Test 1 - 3
---
{% if $foo %}
* Test 2 - 1
* Test 2 - 2
* Test 2 - 3
---
* Test 3 - 1
* Test 3 - 2
* Test 3 - 3
{% /if %}
---
* Test 4 - 1
* Test 4 - 2
* Test 4 - 3
{% /table %}
expected:
- tag: table
children:
- tag: thead
children:
- tag: tr
children:
- tag: th
children: [Test 1 - 1]
- tag: th
children: [Test 1 - 2]
- tag: th
children: [Test 1 - 3]
- tag: tbody
children:
- tag: tr
children:
- tag: td
children: [Test 2 - 1]
- tag: td
children: [Test 2 - 2]
- tag: td
children: [Test 2 - 3]
- tag: tr
children:
- tag: td
children: [Test 3 - 1]
- tag: td
children: [Test 3 - 2]
- tag: td
children: [Test 3 - 3]
- tag: tr
children:
- tag: td
children: [Test 4 - 1]
- tag: td
children: [Test 4 - 2]
- tag: td
children: [Test 4 - 3]
- name: Advanced table with if and else
config:
variables:
foo: false
bar: true
code: |
{% table %}
* Test 1 - 1
* Test 1 - 2
* Test 1 - 3
---
{% if $foo %}
* Test 2 - 1
* Test 2 - 2
* Test 2 - 3
{% else / %}
* Test 2 - 1 - alternate
* Test 2 - 2 - alternate
* Test 2 - 3 - alternate
{% /if %}
---
{% if $bar %}
* Test 3 - 1
* Test 3 - 2
* Test 3 - 3
{% /if %}
{% /table %}
expected:
- tag: table
children:
- tag: thead
children:
- tag: tr
children:
- tag: th
children: [Test 1 - 1]
- tag: th
children: [Test 1 - 2]
- tag: th
children: [Test 1 - 3]
- tag: tbody
children:
- tag: tr
children:
- tag: td
children: [Test 2 - 1 - alternate]
- tag: td
children: [Test 2 - 2 - alternate]
- tag: td
children: [Test 2 - 3 - alternate]
- tag: tr
children:
- tag: td
children: [Test 3 - 1]
- tag: td
children: [Test 3 - 2]
- tag: td
children: [Test 3 - 3]
- name: Advanced table without header
code: |
{% table %}
---
* foo
* bar
{% /table %}
expected:
- tag: table
children:
- tag: thead
- tag: tbody
children:
- tag: tr
children:
- tag: td
children: [foo]
- tag: td
children: [bar]
- name: Advanced table with inner content
code: |
{% table %}
---
* foo
*
```ruby
puts "test"
```
* bar
---
* foo
*
bar
* baz
{% /table %}
expected:
- tag: table
children:
- tag: thead
- tag: tbody
children:
- tag: tr
children:
- tag: td
children: [foo]
- tag: td
children:
- tag: pre
attributes:
data-language: ruby
children: ["puts \"test\"\n"]
- tag: td
children: [bar]
- tag: tr
children:
- tag: td
children: [foo]
- tag: td
children: [bar]
- tag: td
children: [baz]
- name: GFM table syntax surrounded by a table tag
code: |
{% table %}
Foo | Bar
--|--
Test 1 - 1 | Test 1 - 2
Test 2 - 1 | Test 2 - 2
{% /table %}
expected:
- tag: table
children:
- tag: thead
children:
- tag: tr
children:
- tag: th
children: [Foo]
- tag: th
children: [Bar]
- tag: tbody
children:
- tag: tr
children:
- tag: td
children: [Test 1 - 1]
- tag: td
children: [Test 1 - 2]
- tag: tr
children:
- tag: td
children: [Test 2 - 1]
- tag: td
children: [Test 2 - 2]
- name: Advanced table with conditional inside cell
config:
variables:
foo: true
code: |
{% table %}
* Heading 1
* Heading 2
---
* Cell 1
* {% if $foo %}Inline conditional content{% /if %}
---
* Cell 2
* Some content
{% if $foo %}
Conditional block
{% else /%}
Alternate block
{% /if %}
{% /table %}
expected:
- tag: table
children:
- tag: thead
children:
- tag: tr
children:
- tag: th
children: [Heading 1]
- tag: th
children: [Heading 2]
- tag: tbody
children:
- tag: tr
children:
- tag: td
children: [Cell 1]
- tag: td
children: [Inline conditional content]
- tag: tr
children:
- tag: td
children:
- tag: p
children: [Cell 2]
- tag: td
children:
- tag: p
children: [Some content]
- tag: p
children: [Conditional block]
- name: Table with invalid content in body
code: |
{% table %}
* Heading 1
* Heading 2
---
Escaped content
{% /table %}
expectedError: 'Found paragraph where a list was expected. Make sure all content inside table cells is indented.'
- name: Table with invalid conditional content in body
code: |
{% table %}
* Heading 1
* Heading 2
---
* Cell 1
* Cell 2
{% if $foo %}
Escaped content
{% /if %}
{% /table %}
expectedError: 'Found paragraph where a list was expected. Make sure all content inside table cells is indented.'
- name: Closing tag with trailing whitespace
config:
tags:
test:
render: test
attributes:
title:
type: String
code: |
{% test title="asdf" %}
This is a test
{% /test %}
expected:
- tag: test
attributes:
title: asdf
children:
- tag: p
children:
- This is a test
- name: Escaped string in an attribute
config:
tags:
foo:
render: test
attributes:
bar:
type: String
code: |
{% foo bar="test \"testing\" test" /%}
expected:
- tag: test
attributes:
bar: 'test "testing" test'
- name: 2D Array with new line before closing bracket
config:
tags:
test:
render: test
attributes:
foo:
type: Array
code: |
{% test foo=[
[1, 2],
[3, 4]
] /%}
expected:
- tag: test
attributes:
foo: [[1, 2], [3, 4]]
- name: 2D Array with new line and comma before closing bracket
config:
tags:
test:
render: test
attributes:
foo:
type: Array
code: |
{% test foo=[
[1, 2],
[3, 4],
] /%}
expected:
- tag: test
attributes:
foo: [[1, 2], [3, 4]]
- name: 2D Array single line
config:
tags:
test:
render: test
attributes:
foo:
type: Array
code: |
{% test foo=[[1, 2], [3, 4]] /%}
expected:
- tag: test
attributes:
foo: [[1, 2], [3, 4]]
- name: Empty array attribute value
config:
tags:
test:
render: test
attributes:
foo:
type: Array
code: |
{% test foo=[] %}
testing
{% /test %}
expected:
- tag: test
attributes:
foo: []
children:
- tag: p
children:
- testing
- name: Empty hash attribute value
config:
tags:
test:
render: test
attributes:
foo:
type: Object
code: |
{% test foo={} %}
testing
{% /test %}
expected:
- tag: test
attributes:
foo: {}
children:
- tag: p
children:
- testing
- name: Spaces inside of curly braces
config:
tags:
test:
render: test
attributes:
foo:
type: Object
code: |
{% test foo={ bar: 1, baz: 2 } %}
testing
{% /test %}
expected:
- tag: test
attributes:
foo: { bar: 1, baz: 2 }
children:
- tag: p
children:
- testing
- name: Image
code: |

expected:
- tag: p
children:
- tag: img
attributes:
src: '/logo.png'
alt: 'Alt'
- name: Hardbreak expressed with spaces
code: "This is a paragraph \nwith a hardbreak"
expected:
- tag: p
children:
- 'This is a paragraph'
- tag: br
- 'with a hardbreak'
- name: Hardbreak expressed with backslash
code: |
This is a paragraph\
with a hardbreak
expected:
- tag: p
children:
- 'This is a paragraph'
- tag: br
- 'with a hardbreak'
- name: Softbreak
code: |
This is a paragraph
with a softbreak
expected:
- tag: p
children:
- 'This is a paragraph'
- ' '
- 'with a softbreak'
- name: Partial
config:
partials:
foo.md: This is content from a partial
code: |
This is a test
{% partial file="foo.md" variables={foo: 1} /%}
expected:
- tag: p
children: [This is a test]
- tag: p
children: [This is content from a partial]
- name: Multiple partials
config:
partials:
foo.md: |
This is content from a partial
bar.md: |
{% example %}
This is content in another partial
{% /example %}
tags:
example:
render: test
code: |
This is a test
{% partial file="foo.md" /%}
{% partial file="bar.md" /%}
expected:
- tag: p
children: [This is a test]
- tag: p
children: [This is content from a partial]
- tag: test
children:
- tag: p
children:
- This is content in another partial
- name: Partial with a variable
config:
tags:
example:
render: test
attributes:
bar:
render: true
partials:
foo.md: |
{% example bar=$foo %}
This is a partial with a variable
{% /example %}
code: |
This is a test
{% partial file="foo.md" variables={foo: 1} /%}
expected:
- tag: p
children: [This is a test]
- tag: test
attributes:
bar: 1
children:
- tag: p
children:
- 'This is a partial with a variable'
- name: Untruthy things are false
validation: false
config:
variables:
foo: null
bar: false
code: |
This is a test
{% if $foo %}
Nope
{% /if %}
{% if $bar %}
Nope
{% /if %}
{% if $baz %}
Nope
{% /if %}
{% if not("") %}
Nope
{% /if %}
{% if and($foo, $bar) %}
Nope
{% /if %}
expected:
- tag: p
children: [This is a test]
- name: Truthy things are not false
config:
variables:
foo: 0
bar: ''
baz: true
code: |
{% if $foo %}
foo
{% /if %}
{% if $bar %}
bar
{% /if %}
{% if $baz %}
baz
{% /if %}
{% if or(false, $foo) %}
zero
{% /if %}
{% if and($foo, $bar, $baz) %}
and
{% /if %}
expected:
- tag: p
children: [foo]
- tag: p
children: [bar]
- tag: p
children: [baz]
- tag: p
children: [zero]
- tag: p
children: [and]
- name: Strikethroughs
code: '~~Strike~~'
expected:
- tag: p
children:
- tag: s
children: [Strike]
- name: Indented paragraph in a tag
config:
tags:
foo:
render: 'div'
code: |
{% foo %}
{% foo %}
This is a test
{% /foo %}
{% /foo %}
expected:
- tag: div
children:
- tag: div
children:
- tag: p
children: ['This is a test']
- name: Indented fence in a tag
config:
tags:
foo:
render: 'div'
code: |
{% foo %}
{% foo %}
```javascript
console.log('test');
```
{% /foo %}
{% /foo %}
expected:
- tag: div
children:
- tag: div
children:
- tag: pre
attributes:
data-language: javascript
children:
- "console.log('test');\n"
- name: Oddly indented paragraph in a tag
config:
tags:
foo:
render: 'div'
code: |
{% foo %}
{% foo %}
This is a test
{% /foo %}
{% /foo %}
expected:
- tag: div
children:
- tag: div
children:
- tag: p
children: ['This is a test']
- name: Indented paragraph in a tag
config:
tags:
foo:
render: 'div'
code: |
test
* foo
* bar
* baz
* qux
expected:
- tag: p
children: [test]
- tag: ul
children:
- tag: li
children: [foo]
- tag: li
children:
- bar
- tag: ul
children:
- tag: li
children: [baz]
- tag: li
children: [qux]
- name: Indented paragraph in a tag
config:
tags:
foo:
render: 'div'
code: |
{% foo %}
{% foo %}
* foo
* bar
* baz
* qux
* ```javascript
console.log('test');
```
* zxcv
{% /foo %}
{% /foo %}
expected:
- tag: div
children:
- tag: div
children:
- tag: ul
children:
- tag: li
children: [foo]
- tag: li
children:
- bar
- tag: ul
children:
- tag: li
children: [baz]
- tag: li
children: [qux]
- tag: li
children:
- tag: pre
attributes:
data-language: javascript
children:
- "console.log('test');\n"
- tag: li
children: [zxcv]
- name: String hash key
config:
tags:
foo:
render: div
attributes:
bar:
type: Object
code: |
{% foo bar={"this is a test": "test"} %}
testing
{% /foo %}
expected:
- tag: div
attributes:
bar:
this is a test: test
children:
- tag: p
children: [testing]
- name: Illegal string hash key
config:
tags:
foo:
render: div
attributes:
bar:
type: Object
code: |
{% foo bar={"this is a test": "test", "$$mdtype": true} %}
testing
{% /foo %}
expected:
- tag: div
attributes:
bar:
this is a test: test
children:
- tag: p
children: [testing]
- name: Ignoring comments
code: |
# Example <!-- foo -->
This is a test <!-- bar
-->
<!--
baz
-->
expected:
- tag: h1
children: ['Example ']
- tag: p
children: ['This is a test ']
- name: Escaped quotes in tag strings
config:
tags:
foo:
render: foo
attributes:
bar:
type: String
code: |
{% foo bar="this is a test of \"quoted\" strings" /%}
expected:
- tag: foo
attributes:
bar: 'this is a test of "quoted" strings'
- name: Escaped quotes in tag strings with html renderer
renderer: html
config:
tags:
foo:
render: foo
attributes:
bar:
type: String
code: |
{% foo bar="this is a test of \"quoted\" strings" /%}
expected: <article><foo bar="this is a test of "quoted" strings"></foo></article>
- name: Escaped newline in tag strings
config:
tags:
foo:
render: foo
attributes:
bar:
type: String
code: |
{% foo bar="this is a test\nof a newline in a tag" /%}
expected:
- tag: foo
attributes:
bar: |-
this is a test
of a newline in a tag
- name: Basic slot
config:
tags:
foo:
render: foo
slots:
bar: {}
code: |
{% foo %}
{% slot "bar" %}
This is a test
{% /slot %}
{% /foo %}
slots: true
expected:
- tag: foo
attributes:
bar:
- tag: p
children:
- This is a test
- name: Tag with multiple slots and additional content
config:
tags:
foo:
render: foo
attributes:
qux:
type: String
slots:
bar: {}
baz: {}
code: |
{% foo qux="test" %}
{% slot "bar" %}
This is a test
{% /slot %}
{% slot "baz" %}
This is **another** test
{% /slot %}
This is additional content
{% /foo %}
slots: true
expected:
- tag: foo
attributes:
qux: test
bar:
- tag: p
children:
- This is a test
baz:
- tag: p
children:
- 'This is '
- tag: strong
children: [another]
- ' test'
children:
- tag: p
children:
- This is additional content
- name: User slot tag when slots are disabled
config:
tags:
slot:
render: foo
code: |
{% slot %}
bar
{% /slot %}
expected:
- tag: foo
children:
- tag: p
children: [bar]
- name: Handling slots that are missing a name
config:
tags:
foo:
render: foo
attributes:
bar:
type: Node
code: |
{% foo %}
{% slot %}
This is a test
{% /slot %}
{% /foo %}
slots: true
expectedError: "Missing required attribute: 'primary'"
expected:
- tag: foo
children: [null]
- name: Handling slots with invalid name
config:
tags:
foo:
render: foo
attributes:
bar:
type: Node
code: |
{% foo %}
{% slot 1 %}
This is a test
{% /slot %}
{% /foo %}
slots: true
expectedError: "Attribute 'primary' must be type of 'String'"
expected:
- tag: foo
children: [null]
- name: Validating required slot
config:
tags:
foo:
render: foo
slots:
bar:
required: true
code: |
{% foo %}
{% /foo %}
slots: true
expectedError: "Missing required slot: 'bar'"
expected:
- tag: foo
- name: Handling invalid slot
config:
tags:
foo:
render: foo
code: |
{% foo %}
{% slot "bar" %}
This is a test
{% /slot %}
{% /foo %}
slots: true
expectedError: "Invalid slot: 'bar'"
expected:
- tag: foo
- name: Handling overlapping slot and attribute
config:
tags:
foo:
render: foo
attributes:
bar:
type: String
slots:
bar: {}
code: |
{% foo bar="test" %}
{% /foo %}
{% foo bar="test" %}
{% slot "bar" %}
test
{% /slot %}
{% /foo %}
{% foo %}
{% slot "bar" %}
test
{% /slot %}
{% /foo %}
slots: true
expected:
- tag: foo
attributes:
bar: 'test'
- tag: foo
attributes:
bar:
- tag: p
children: [test]
- tag: foo
attributes:
bar:
- tag: p
children: [test]
- name: Hnadling slot that doesn't render
config:
tags:
foo:
render: foo
slots:
bar:
render: false
slots: true
code: |
{% foo %}
this is a test
{% slot "bar" %}
test
{% /slot %}
{% /foo %}
expected:
- tag: foo
children:
- tag: p
children: [this is a test]
- name: Slot with a variable
config:
variables:
example: test
tags:
foo:
render: foo
slots:
bar: {}
code: |
{% foo %}
{% slot "bar" %}
This is a {% $example %}
{% /slot %}
{% /foo %}
slots: true
expected:
- tag: foo
attributes:
bar:
- tag: p
children: ['This is a ', 'test']
- name: Multiline block tags
config:
tags:
foo:
render: foo
code: |
{%
foo
#bar
%}
This is a test
{% /foo %}
expected:
- tag: foo
attributes:
id: bar
children:
- tag: p
children: [This is a test]
- name: Multiline block tags with closing on line with content
config:
tags:
foo:
render: foo
code: |
{% foo
#bar %}
This is a test
{% /foo %}
expected:
- tag: foo
attributes:
id: bar
children:
- tag: p
children: [This is a test]