Skip to content

Commit 30cadaf

Browse files
committed
Update 3-Templates.md
1 parent 17cf279 commit 30cadaf

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

docs/3-Templates.md

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -600,16 +600,12 @@ _Examples:_
600600
```twig
601601
{# image width in pixels #}
602602
{{ asset('image.png').width }}px
603-
604603
{# photo's date in seconds #}
605604
{{ asset('photo.jpeg').exif.EXIF.DateTimeOriginal|date('U') }}
606-
607605
{# audio duration in seconds #}
608606
{{ asset('song.mp3').duration|round }} s
609-
610607
{# video duration in seconds #}
611608
{{ asset('movie.mp4').duration|round }} s
612-
613609
{# file integrity hash #}
614610
{% set integrity = asset('styles.scss').integrity %}
615611
```
@@ -637,9 +633,6 @@ Creates an HTML element from an asset (or an array of assets with custom attribu
637633

638634
```twig
639635
{{ html(asset, {attributes}, {options}) }}
640-
```
641-
642-
```twig
643636
{# dedicated functions for each common type of asset #}
644637
{{ css(asset) }}
645638
{{ js(asset) }}
@@ -666,47 +659,23 @@ _Examples:_
666659
```twig
667660
{# CSS with an attribute #}
668661
{{ html(asset('print.css'), {media: 'print'}) }}
669-
```
670-
671-
```twig
672662
{# CSS with an attribute and an option #}
673663
{{ html(asset('styles.css'), {title: 'Main theme'}, {preload: true}) }}
674-
```
675-
676-
```twig
677664
{# Array of assets with media query #}
678665
{{ html([
679666
{asset: asset('css/style.css')},
680667
{asset: asset('css/style-dark.css'), attributes: {media: '(prefers-color-scheme: dark)'}}
681668
]) }}
682-
```
683-
684-
```twig
685669
{# JavaScript #}
686670
{{ html(asset('script.js')) }}
687-
```
688-
689-
```twig
690671
{# image without specific attributes nor options #}
691672
{{ html(asset('image.png')) }}
692-
```
693-
694-
```twig
695673
{# image with specific attributes, responsive images and alternative formats #}
696674
{{ html(asset('image.jpg'), {alt: 'Description', loading: 'lazy'}, {responsive: true, formats: ['avif', 'webp']}) }}
697-
```
698-
699-
```twig
700675
{# image with responsive pixels density images #}
701676
{{ html(asset('image.jpg'), options={responsive: 'density'}, attributes={width: 256}) }}
702-
```
703-
704-
```twig
705677
{# Audio #}
706678
{{ html(asset('audio.mp3')) }}
707-
```
708-
709-
```twig
710679
{# Video #}
711680
{{ html(asset('video.mp4')) }}
712681
```
@@ -849,13 +818,13 @@ Sorts a collection by date (most recent first).
849818
_Example:_
850819

851820
```twig
852-
# sort by date
821+
{# sort by date #}
853822
{{ site.pages|sort_by_date }}
854-
# sort by updated variable instead of date
823+
{# sort by updated variable instead of date #}
855824
{{ site.pages|sort_by_date(variable='updated') }}
856-
# sort items with the same date by desc title
825+
{# sort items with the same date by desc title #}
857826
{{ site.pages|sort_by_date(desc_title=true) }}
858-
# reverse sort
827+
{# reverse sort #}
859828
{{ site.pages|sort_by_date|reverse }}
860829
```
861830

@@ -1475,7 +1444,7 @@ Uses the Twig [`format_date`](https://twig.symfony.com/doc/3.x/filters/format_da
14751444

14761445
```twig
14771446
{{ page.date|format_date('long') }}
1478-
# September 30, 2022
1447+
{# September 30, 2022 #}
14791448
```
14801449

14811450
Supported values are: `short`, `medium`, `long`, and `full`.
@@ -1551,7 +1520,7 @@ To use _fragments_ cache, you must wrap the content you want to cache with the `
15511520
15521521
```twig
15531522
{% cache 'unique-key' %}
1554-
{# content #}
1523+
{# content #}
15551524
{% endcache %}
15561525
```
15571526

0 commit comments

Comments
 (0)