Skip to content

Commit 457f80f

Browse files
committed
Reference landing pages list their subpages
1 parent 3af2843 commit 457f80f

File tree

8 files changed

+105
-27
lines changed

8 files changed

+105
-27
lines changed

docs/5.x/development/twig.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,35 @@ Let’s take a look at how it works.
1515

1616
## Types of Twig code
1717

18-
Twig templates are HTML files that are sprinkled with bits of Twig code. When Twig loads a template, the first thing it will do is separate the raw HTML code from the Twig code. The raw HTML code will be output to the browser without any tampering.
18+
Twig templates are HTML files that are sprinkled with bits of logic. When Twig loads a template, the first thing it does is identify which parts of the file represent Twig code.
1919

20-
All Twig code follows a basic pattern that separates it from the surrounding HTML. At its outer edges you will find left and right curly braces (`{` and `}`), coupled with another character that signifies what _type_ of Twig code it is. These sets of characters are called “delimiters”.
20+
All Twig code follows a basic pattern that separates it from the surrounding HTML. At its outer edges you will find left and right curly braces (`{` and `}`), coupled with another character that signifies what type of Twig expression it expects to be inside. These pairs of characters are called _delimiters_.
2121

22-
There are three types of delimiters that Twig looks out for:
22+
There are three types of delimiters that Twig parses:
2323

24-
- `{#`[Comments](#comments)
25-
- `{%`[Tags](#tags)
26-
- `{{`[Print statements](#print-statements)
24+
- `{# ... #}`[Comments](#comments)
25+
- `{% ... %}`[Tags](#tags)
26+
- `{{ ... }}`[Print statements](#print-statements)
2727

2828
### Comments
2929

3030
Twig comments are wrapped in `{#` and `#}` delimiters. You can use them to leave little notes for yourself in the code.
3131

32-
They are similar to HTML comments in that they won’t show up as rendered text in the browser. The difference is that they will never make it into the HTML source in the first place.
32+
They are similar to HTML comments in that they won’t show up as rendered text in the browser—but _Twig_ comments are stripped from the HTML output:
3333

34-
```twig
35-
<!-- This will be visible in the HTML source -->
34+
::: code
35+
```twig Template
36+
<!-- This will be visible in the HTML source! -->
3637
{# This won’t! #}
3738
```
39+
```html Output
40+
<!-- This will be visible in the HTML source! -->
41+
```
42+
:::
3843

3944
### Tags
4045

41-
Twig tags are wrapped in `{%` and `%}` delimiters, and are used to define the _logic_ of your template, such as conditionals, loops, variable definitions, template includes, and other things.
46+
Twig tags are wrapped in `{%` and `%}` delimiters, and are used to define the _logic_ of your template, such as conditionals, loops, variable definitions, template includes, and other instructions.
4247

4348
The syntax within the `{%` and `%}` delimiters varies from tag to tag, but they will always start with the same thing: the name of the tag.
4449

@@ -68,17 +73,17 @@ Some tags can have nested tags _between_ the opening and closing tags:
6873

6974
```twig
7075
{% if currentUser %}
71-
<a href="/logout">Logout</a>
76+
<a href="{{ logoutUrl }}">Logout</a>
7277
{% else %}
73-
<a href="/login">Login</a>
78+
<a href="{{ loginUrl }}">Login</a>
7479
{% endif %}
7580
```
7681

7782
Refer to the [Tags](../reference/twig/tags.md) page for a full list of tags available to your Craft templates.
7883

7984
### Print Statements
8085

81-
To output dynamic values, use a print statement. Print statements are opened and closed with `{{` and `}}` delimiters, respectively, can contain any valid Twig expression—so long as it produces something that can be treated as a [string](#strings).
86+
To output dynamic values, use a print statement. Print statements are opened and closed with `{{` and `}}` delimiters, respectively, and can contain any valid Twig expression—so long as it produces something that can be treated as a [string](#strings).
8287

8388
```twig
8489
<p>Hi, {{ currentUser.name }}</p>

docs/5.x/reference/README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,26 @@
22

33
This section contains technical details for built-in Craft components like [element types](element-types/), [field types](field-types/), and the [Twig environment](twig/). It is intended primarily for developers charged with building or maintaining a Craft project who need frequent access to code-specific features.
44

5-
See the sidebar for a complete list of topics.
5+
[Element Types](element-types/README.md) &rarr;
6+
: Deep-dives on each of Craft’s built-in [element types](../system/elements.md).
7+
8+
[Field Types](field-types/README.md) &rarr;
9+
: Discover Craft’s built-in [field types](../system/fields.md).
10+
11+
[Configuration](config/README.md) &rarr;
12+
: Descriptions for every [general](config/general.md) and [database](config/db.md) config setting, as well as help with [application config](config/app.md).
13+
14+
[Twig](twig/README.md) &rarr;
15+
: Lists of filters, functions, tags, tests, and variables that Craft provides to the [Twig templating environment](../development/twig.md).
16+
17+
[Controller Actions](controller-actions.md) &rarr;
18+
: Common HTTP endpoints for use with [forms](../development/forms.md).
19+
20+
[Command-Line Interface](cli.md) &rarr;
21+
: Special back-office features available via the command line.
622

723
## Additional Resources
824

9-
<See url="https://github.com/craftcms/cms" label="Craft CMS Source" description="Browse Craft’s source code on GitHub." />
25+
<See url="https://github.com/craftcms/cms" label="Craft CMS Source" description="Browse Craft’s source code, releases, issues, and discussions on GitHub." />
26+
27+
<See url="https://docs.craftcms.com/api/v5" label="Class Reference" description="Auto-generated class reference for Craft CMS 5.x." />

docs/5.x/reference/cli.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ containsGeneratedContent: yes
99

1010
The complete list of available commands will include those from any plugins or custom modules you’ve added to your project. Only those that are present by default in all Craft installations are listed below.
1111

12+
::: tip
13+
Run `ddev craft help` to see a list of commands your project supports.
14+
:::
15+
1216
### Global Options
1317

1418
All commands support the following options:

docs/5.x/reference/config/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
11
# Configuration Reference
2+
3+
These pages contain comprehensive reference for Craft’s configuration files:
4+
5+
<See path="general.md" />
6+
<See path="db.md" />
7+
8+
Additional sections cover abstract configuration schemes:
9+
10+
<See path="app.md" />
11+
<See path="bootstrap.md" />

docs/5.x/reference/config/app.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
description: Customize and extend core application components.
23
related:
34
- uri: ../../configure.md
45
label: Configuring Craft
@@ -26,6 +27,8 @@ Of course, this power comes with a greater risk of misconfiguration. Some compon
2627
Keep in mind that even when Craft doesn’t provide “defaults” explicitly in its own `app.php` config files (or config helper methods), the underlying component classes may have default property values—or even compute defaults based on other values.
2728
:::
2829

30+
You may place configuration directly in `config/app.php`, or use `config/app.web.php` or `config/app.console.php` to apply it specifically to one app context. Defining options in the global space may cause errors for components that Craft itself only uses in one context or the other!
31+
2932
### Static
3033

3134
Most components’ config can be provided as a plain array, which gets merged with the default config map prior to initialization. This style is mostly used for customizing individual properties on a component:

docs/5.x/reference/config/bootstrap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Reference
2+
description: Customize your project’s directory structure and other low-level behaviors.
33
related:
44
- uri: ../../configure.md
55
label: Configuring Craft

docs/5.x/reference/twig/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Twig Reference
22

3+
This section covers features available in Twig, Craft’s template environment.
4+
35
<See path="../../development/twig.md" label="Twig Fundamentals" />
46

57
<hr>

docs/5.x/reference/twig/functions.md

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -495,20 +495,38 @@ Creates and returns a new <yii2:yii\db\Expression> object, for use in database q
495495

496496
## `failMessageInput`
497497

498-
Shortcut for typing `<input type="hidden" name="failMessage" value="{{ 'Custom fail message'|hash }}">`.
498+
Renders a hidden `input` element with a tamper-proof [failure](../../development/forms.md#failure) message.
499499

500-
```twig
501-
{{ failMessageInput('Custom fail message') }}
500+
```twig{3}
501+
<form method="post">
502+
{{ actionInput('users/save-user') }}
503+
{{ failMessageInput('Something went wrong when updating your profile.') }}
504+
505+
{# ... #}
506+
</form>
502507
```
503508

504-
You can optionally set additional attributes on the tag by passing an `options` argument.
509+
You can set additional attributes on the `input` tag by passing an `options` argument:
505510

506511
```twig
507-
{{ failMessageInput('Custom fail message', {
508-
id: 'fail-message-input'
512+
{{ failMessageInput('Something went wrong when updating your profile.', {
513+
id: 'failure-message-input'
509514
}) }}
510515
```
511516

517+
The output is equivalent to this Twig:
518+
519+
```twig
520+
<input
521+
type="hidden"
522+
name="failMessage"
523+
value="{{ 'Something went wrong when updating your profile.'|hash }}">
524+
```
525+
526+
Failure messages are stored in the session as [flashes](../../development/forms.md#flashes).
527+
528+
<See path="../../development/forms.md" label="Working with Forms" />
529+
512530
## `fieldValueSql`
513531

514532
Generates a platform-specific SQL expression to extract a value from elements’ JSON content column.
@@ -827,20 +845,38 @@ This works identically to Twig’s core [`source`](https://twig.symfony.com/doc/
827845

828846
## `successMessageInput`
829847

830-
Shortcut for typing `<input type="hidden" name="successMessage" value="{{ 'Custom success message'|hash }}">`.
848+
Renders a hidden `input` element with a tamper-proof [success](../../development/forms.md#success) message.
831849

832-
```twig
833-
{{ successMessageInput('Custom success message') }}
850+
```twig{3}
851+
<form method="post">
852+
{{ actionInput('users/save-user') }}
853+
{{ successMessageInput('Your profile has been updated!') }}
854+
855+
{# ... #}
856+
</form>
834857
```
835858

836-
You can optionally set additional attributes on the tag by passing an `options` argument.
859+
You can set additional attributes on the `input` tag by passing an `options` argument:
837860

838861
```twig
839-
{{ successMessageInput('Custom success message', {
862+
{{ successMessageInput('Your profile has been updated!', {
840863
id: 'success-message-input'
841864
}) }}
842865
```
843866

867+
The output is equivalent to this Twig:
868+
869+
```twig
870+
<input
871+
type="hidden"
872+
name="successMessage"
873+
value="{{ 'Your profile has been updated!'|hash }}">
874+
```
875+
876+
Success messages are stored in the session as [flashes](../../development/forms.md#flashes).
877+
878+
<See path="../../development/forms.md" label="Working with Forms" />
879+
844880
## `svg`
845881

846882
Outputs an SVG document.

0 commit comments

Comments
 (0)