Skip to content

Commit 924e02f

Browse files
authored
Merge pull request #122 from getherbie/2.x-develop
2.x develop
2 parents cbd0840 + 534bf79 commit 924e02f

6 files changed

Lines changed: 28 additions & 20 deletions

File tree

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ TBD
5555
The easiest way to install Herbie is through Composer.
5656
Run the following commands in your terminal to create a new project and install all dependent libraries.
5757

58-
For the upcoming 2.x version (PHP 8.x):
59-
60-
composer create-project getherbie/start-website:dev-master mywebsite
61-
62-
For the stable 1.x version (PHP 5.6):
63-
6458
composer create-project getherbie/start-website mywebsite
6559

6660
Change to the `mywebsite/web` directory:

tests/website/WebsiteCest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ public function testDocContentsVariables(AcceptanceTester $I)
129129
$I->seeResponseCodeIs(HttpCode::OK);
130130
$I->see('Variables', 'h1');
131131
$I->see('On this page', '.toc-title');
132-
$I->seeNumberOfElements('.content>h2', 3);
133-
$I->seeNumberOfElements('.content>p', 3);
132+
$I->seeNumberOfElements('.content>h2', 4);
133+
$I->seeNumberOfElements('.content>p', 4);
134134
$I->seeNumberOfElements('.content>pre', 1);
135-
$I->seeNumberOfElements('.content>table', 3);
135+
$I->seeNumberOfElements('.content>table', 4);
136136
}
137137

138138
public function testDocContentsDataFiles(AcceptanceTester $I)

website/site/data/vars_content.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: content.default
3+
desc: The default content segment to be displayed.
4+
This is always available.
5+
type: string
6+
- name: content.<name>
7+
desc: Other named content segments depending on the segments used in your layout files.
8+
type: string

website/site/data/vars_global.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: content
33
desc: The rendered content with one or more content segments.
4-
Only available in layout files.
4+
Available only in layout files.
55
type: array
66
- name: page
77
desc: The page object with its properties and methods.

website/site/pages/2-doc/3-contents/5-variables.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,32 @@ layout: doc
55

66
# Variables
77

8-
Herbie traverses certain directories of the website and processes text files with a page properties block.
9-
For each of these files, Herbie generates different data and makes it available through the Twig template engine.
8+
Herbie crawls certain directories of the website and processes text files that contain a page properties block.
9+
For each of these files, different data is generated and made available in the templating system.
10+
11+
To avoid polluting the global namespace, this data is wrapped in three objects.
12+
These objects can be accessed in the layout and content files using normal Twig variables.
1013

11-
All variables can then be accessed in the layout and content files as normal Twig variables.
1214
Here are some examples:
1315

1416
{% verbatim %}
15-
{{ site.route }}
16-
{{ site.language }}
17-
{{ site.data.persons }}
17+
{{ content.default }}
18+
{{ page.title }}
1819
{{ page.layout }}
19-
{{ page.tags }}
20+
{{ site.language }}
21+
{{ site.route }}
2022
{% endverbatim %}
2123

22-
The details of these variables are listed below.
24+
More details on these variables are provided below.
2325

2426
## Global variables
2527

2628
{{ snippet("@site/snippets/variables.twig", {type:"vars_global"}) }}
2729

30+
## Content variables
31+
32+
{{ snippet("@site/snippets/variables.twig", {type:"vars_content"}) }}
33+
2834
## Page variables
2935

3036
{{ snippet("@site/snippets/variables.twig", {type:"vars_page"}) }}

website/site/pages/2-doc/3-contents/6-data-files.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ In a template you then output the list of persons as follows:
3939

4040
{% verbatim %}
4141
{% for person in site.data.persons %}
42-
<p>Name: {{person.name}}<br>
43-
Instrument: {{person.name}}</p>
42+
<p>Name: {{ person.name }}<br>
43+
Instrument: {{ person.instrument }}</p>
4444
{% endfor %}
4545
{% endverbatim %}

0 commit comments

Comments
 (0)