File: layout_data.feature

package info (click to toggle)
jekyll 4.4.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,488 kB
  • sloc: ruby: 16,736; javascript: 1,455; sh: 216; xml: 29; makefile: 9
file content (90 lines) | stat: -rw-r--r-- 2,902 bytes parent folder | download | duplicates (5)
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
Feature: Layout data
  As a hacker who likes to avoid repetition
  I want to be able to embed data into my layouts
  In order to make the layouts slightly dynamic

  Scenario: Use custom layout data
    Given I have a _layouts directory
    And I have a "_layouts/999.html" file with content:
      """
      ---
      ---
      {{ content }} layout content
      """
    And I have an "index.html" page with layout "custom" that contains "page content"
    And I have an "index.html" file with content:
      """
      ---
      layout: 999
      ---
      page content
      """
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "page content layout content" in "_site/index.html"

  Scenario: Use custom layout data
    Given I have a _layouts directory
    And I have a "_layouts/custom.html" file with content:
      """
      ---
      foo: my custom data
      ---
      {{ content }} foo: {{ layout.foo }}
      """
    And I have an "index.html" page with layout "custom" that contains "page content"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "page content\n foo: my custom data" in "_site/index.html"

  Scenario: Inherit custom layout data
    Given I have a _layouts directory
    And I have a "_layouts/custom.html" file with content:
      """
      ---
      layout: base
      foo: my custom data
      ---
      {{ content }}
      """
    And I have a "_layouts/base.html" file with content:
      """
      {{ content }} foo: {{ layout.foo }}
      """
    And I have an "index.html" page with layout "custom" that contains "page content"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "page content\n foo: my custom data" in "_site/index.html"

  Scenario: Inherit custom layout data and clear when not present
    Given I have a _layouts directory
    And I have a "_layouts/default.html" file with content:
      """
      ---
      bar: i'm default
      ---
      {{ content }} foo: '{{ layout.foo }}' bar: '{{ layout.bar }}'
      """
    And I have a "_layouts/special.html" file with content:
      """
      ---
      layout: default
      foo: my special data
      bar: im special
      ---
      {{ content }}
      """
    And I have a "_layouts/page.html" file with content:
      """
      ---
      layout: default
      bar: im page
      ---
      {{ content }}
      """
    And I have an "index.html" page with layout "special" that contains "page content"
    And I have an "jekyll.html" page with layout "page" that contains "page content"
    When I run jekyll build
    Then the "_site/index.html" file should exist
    And I should see "page content\n foo: 'my special data' bar: 'im special'" in "_site/index.html"
    And I should see "page content\n foo: '' bar: 'im page'" in "_site/jekyll.html"