File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5555The easiest way to install Herbie is through Composer.
5656Run 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
6660Change to the ` mywebsite/web ` directory:
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff 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.
1214Here 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"}) }}
Original file line number Diff line number Diff 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 %}
You can’t perform that action at this time.
0 commit comments