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
@@ -364,12 +366,12 @@ This also means that you can declare them with parameters and can use those para
364
366
The same applies to Slim templates:
365
367
```slim
366
368
@slim SiteLayout(title string) {
367
-
doctype html
368
-
html(lang="en")
369
-
head
370
-
title= title
371
-
body
372
-
/ ... the rest of the template
369
+
doctype html
370
+
html(lang="en")
371
+
head
372
+
title= title
373
+
body
374
+
/ ... the rest of the template
373
375
}
374
376
```
375
377
@@ -381,7 +383,7 @@ Only the HTML 5 doctype is supported, and is written using `!!!`.
381
383
}
382
384
383
385
@slim SiteLayout() {
384
-
doctype
386
+
doctype
385
387
}
386
388
```
387
389
@@ -432,7 +434,15 @@ You would write this with Go (Go needs the `!= nil` check):
432
434
```
433
435
There is minimal processing performed on the Go code you put into the templates, so it needs to be valid Go code sans braces.
434
436
435
-
> You may continue to use the braces if you wish. Existing code with braces will continue to work without modifications.
437
+
Long statements can be split over by ending a line with either a backslash `\` or a comma `,`.
438
+
439
+
```haml
440
+
- if user != nil && user.Name != ""\
441
+
&& user.Age > 0
442
+
%strong The user is not empty
443
+
```
444
+
445
+
> You may continue to use the braces at the ends of your lines if you wish. Existing code with braces will continue to work without modifications.
436
446
437
447
### Rendering code
438
448
Like in Haml, you can output variables and the results of expressions. The `=` script syntax and text interpolation `#{}` are supported for both template languages.
@@ -455,11 +465,11 @@ You would need to write this:
455
465
```haml
456
466
%strong= fmt.Sprintf("%d", user.Age)
457
467
```
458
-
Which to be honest can be a bit long to write, so a shortcut is provided:
468
+
Which, to be honest, can be a bit long to write, so a shortcut is provided:
459
469
```haml
460
470
%strong=%d user.Age
461
471
```
462
-
The interpolation also supports the shortcut:
472
+
The interpolation syntax also supports the shortcut:
463
473
```haml
464
474
%strong #{user.Name} is #{%d user.Age} years old.
465
475
```
@@ -505,8 +515,8 @@ Keep in mind that attribute names cannot be replaced with an interpolated string
505
515
To support dynamic lists of attributes, you can use the `@attributes` directive.
506
516
This directive takes a list of arguments which comes in two forms:
507
517
-`map[string]string`
508
-
- The key is the attribute name, the value is the attribute value.
509
-
- The attribute will be rendered if the value is not empty.
518
+
- The key is the attribute name, the value is the attribute value.
519
+
- The attribute will be rendered if the value is not empty.
510
520
-`map[string]bool`
511
521
- The key is the attribute name, the value is the condition to render the attribute.
512
522
```haml
@@ -521,11 +531,11 @@ GoHT supports the `.` operator for classes and also will accept the `class` attr
521
531
However, if the class attribute is given an interpolated value, it will need to be a comma separated list of values.
522
532
These values can be the following types:
523
533
-`string`
524
-
- `myClass` variable or `"foo bar"` string literal
534
+
-`myClass` variable or `"foo bar"` string literal
525
535
-`[]string`
526
-
- Each item will be added to the class list if it is not blank.
536
+
- Each item will be added to the class list if it is not blank.
527
537
-`map[string]bool`
528
-
- The key is the class name, the value is the condition to include the class.
538
+
- The key is the class name, the value is the condition to include the class.
529
539
530
540
Examples:
531
541
```haml
@@ -558,9 +568,9 @@ GoHT supports inlining tags to keep templates as compact as possible.
0 commit comments