You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/1-essentials/02-views.md
+18-3Lines changed: 18 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -177,7 +177,7 @@ Apart from HTMLs boolean attributes, the same syntax can be used with any expres
177
177
178
178
### Control flow directives
179
179
180
-
#### `:if`, `:elseif` and `:else`
180
+
#### `:if`, `:elseif`, and `:else`
181
181
182
182
The `:if` directive can conditionally render the element it is attached to, depending on the result of its expression. Similarly, the `:elseif` and `:else` directives can be used on direct siblings for additional control.
183
183
@@ -186,6 +186,21 @@ The `:if` directive can conditionally render the element it is attached to, depe
The `:isset` directive can be used to conditionally render the element it is attached to, depending on the existence of a variable.
192
+
193
+
```html
194
+
<h1:isset="$title">{{ $title }}</h1>
195
+
```
196
+
197
+
Since `:isset` is a shorthand for `:if="isset()"`, it can be combined with `:elseif` and `:else`:
198
+
199
+
```html
200
+
<h1:isset="$title">{{ $title }}</h1>
201
+
<h1:else>Title</h1>
202
+
```
203
+
189
204
#### `:foreach` and `:{:hl-keyword:forelse:}`
190
205
191
206
The `:foreach` directive may be used to render the associated element multiple times based on the result of its expression. Combined with `:{:hl-keyword:forelse:}`, an empty state can be displayed when the data is empty.
@@ -230,7 +245,7 @@ To create a view component, create a `.view.php` file that starts with `x-`. The
Copy file name to clipboardExpand all lines: docs/4-internals/03-view-spec.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Some frontend frameworks also provide a `{html}:{:hl-property:attribute:}` synta
27
27
28
28
### Control structures
29
29
30
-
Control structures like conditionals and loops are modelled with expression attributes. These control structure attributes are available: `{html}:{:hl-property:if:}`, `{html}:{:hl-property:elseif:}`, `{html}:{:hl-property:else:}`, `{html}:{:hl-property:foreach:}`, `{html}:{:hl-property:forelse:}`. Code within these control structures is compiled to valid PHP expressions.
30
+
Control structures like conditionals and loops are modelled with expression attributes. These control structure attributes are available: `{html}:{:hl-property:if:}`, `{html}:{:hl-property:elseif:}`, `{html}:{:hl-property:else:}`, {:hl-property:isset:}`, `{html}:{:hl-property:foreach:}`, `{html}:{:hl-property:forelse:}`. Code within these control structures is compiled to valid PHP expressions.
0 commit comments