forked from jekyll/jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathembed_filters.feature
161 lines (152 loc) · 7.77 KB
/
embed_filters.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
Feature: Embed filters
As a hacker who likes to blog
I want to be able to transform text inside a post or page
In order to perform cool stuff in my posts
Scenario: Convert date to XML schema
Given I have a _posts directory
And I have a _layouts directory
And I have the following post:
| title | date | layout | content |
| Star Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
And I have a default layout that contains "{{ site.time | date_to_xmlschema }}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see today's date in "_site/2009/03/27/star-wars.html"
Scenario: Escape text for XML
Given I have a _posts directory
And I have a _layouts directory
And I have the following post:
| title | date | layout | content |
| Star & Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
And I have a default layout that contains "{{ page.title | xml_escape }}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "Star & Wars" in "_site/2009/03/27/star-wars.html"
Scenario: Calculate number of words
Given I have a _posts directory
And I have a _layouts directory
And I have the following post:
| title | date | layout | content |
| Star Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
And I have a default layout that contains "{{ content | number_of_words }}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "7" in "_site/2009/03/27/star-wars.html"
Scenario: Convert an array into a sentence
Given I have a _posts directory
And I have a _layouts directory
And I have the following post:
| title | date | layout | tags | content |
| Star Wars | 2009-03-27 | default | [scifi, movies, force] | These aren't the droids you're looking for. |
And I have a default layout that contains "{{ page.tags | array_to_sentence_string }}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "scifi, movies, and force" in "_site/2009/03/27/star-wars.html"
Scenario: Markdownify a given string
Given I have a _posts directory
And I have a _layouts directory
And I have the following post:
| title | date | layout | content |
| Star Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
And I have a default layout that contains "By {{ '_Obi-wan_' | markdownify }}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "By <p><em>Obi-wan</em></p>" in "_site/2009/03/27/star-wars.html"
Scenario: Sort by an arbitrary variable
Given I have a _layouts directory
And I have the following page:
| title | layout | value | content |
| Page-1 | default | 8 | Something |
And I have the following page:
| title | layout | value | content |
| Page-2 | default | 6 | Something |
And I have a default layout that contains "{{ site.pages | sort:'value' | map:'title' | join:', ' }}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see exactly "Page-2, Page-1" in "_site/page-1.html"
And I should see exactly "Page-2, Page-1" in "_site/page-2.html"
Scenario: Sort pages by the title
Given I have a _layouts directory
And I have the following pages:
| title | layout | content |
| Dog | default | Run |
| Bird | default | Fly |
And I have the following page:
| layout | content |
| default | Jump |
And I have a default layout that contains "{% assign sorted_pages = site.pages | sort: 'title' %}The rule of {{ sorted_pages.size }}: {% for p in sorted_pages %}{{ p.content | strip_html | strip_newlines }}, {% endfor %}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see exactly "The rule of 3: Jump, Fly, Run," in "_site/bird.html"
Scenario: Sort pages by the title ordering pages without title last
Given I have a _layouts directory
And I have the following pages:
| title | layout | content |
| Dog | default | Run |
| Bird | default | Fly |
And I have the following page:
| layout | content |
| default | Jump |
And I have a default layout that contains "{% assign sorted_pages = site.pages | sort: 'title', 'last' %}The rule of {{ sorted_pages.size }}: {% for p in sorted_pages %}{{ p.content | strip_html | strip_newlines }}, {% endfor %}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see exactly "The rule of 3: Fly, Run, Jump," in "_site/bird.html"
Scenario: Filter posts by given property and value
Given I have a _posts directory
And I have the following posts:
| title | date | content | property |
| Bird | 2019-03-13 | Chirp | [nature, sounds] |
| Cat | 2019-03-14 | Meow | [sounds] |
| Dog | 2019-03-15 | Bark | |
| Elephant | 2019-03-16 | Asiatic | wildlife |
| Goat | 2019-03-17 | Mountains | "" |
| Horse | 2019-03-18 | Mustang | [] |
| Iguana | 2019-03-19 | Reptile | {} |
| Jaguar | 2019-03-20 | Reptile | {foo: lorem, bar: nature} |
And I have a "string-value.md" page with content:
"""
{% assign pool = site.posts | reverse | where: 'property', 'wildlife' %}
{{ pool | map: 'title' | join: ', ' }}
"""
And I have a "string-value-array.md" page with content:
"""
{% assign pool = site.posts | reverse | where: 'property', 'sounds' %}
{{ pool | map: 'title' | join: ', ' }}
"""
And I have a "string-value-hash.md" page with content:
"""
{% assign pool = site.posts | reverse | where: 'property', 'nature' %}
{{ pool | map: 'title' | join: ', ' }}
"""
And I have a "nil-value.md" page with content:
"""
{% assign pool = site.posts | reverse | where: 'property', nil %}
{{ pool | map: 'title' | join: ', ' }}
"""
And I have an "empty-liquid-literal.md" page with content:
"""
{% assign pool = site.posts | reverse | where: 'property', empty %}
{{ pool | map: 'title' | join: ', ' }}
"""
And I have a "blank-liquid-literal.md" page with content:
"""
{% assign pool = site.posts | reverse | where: 'property', blank %}
{{ pool | map: 'title' | join: ', ' }}
"""
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see exactly "<p>Elephant</p>" in "_site/string-value.html"
And I should see exactly "<p>Bird, Cat</p>" in "_site/string-value-array.html"
And I should see exactly "<p>Bird</p>" in "_site/string-value-hash.html"
And I should see exactly "<p>Dog</p>" in "_site/nil-value.html"
And I should see exactly "<p>Dog, Goat, Horse, Iguana</p>" in "_site/empty-liquid-literal.html"
And I should see exactly "<p>Dog, Goat, Horse, Iguana</p>" in "_site/blank-liquid-literal.html"