How to center text with Markdown?

Markdown does not support this feature natively, but you can achieve this wrapping Markdown into HTML. As a rule of thumb, most ‘flavors’ of Markdown will render this as centered text: <p style=”text-align: center;”>Centered text</p> Specifically for Grav, as their documentation states, you should do these following steps: in your system configuration file user/config/system.yaml make … Read more

Twig sort array of objects by field

Starting with Twig 2.12 (released on October 5, 2019) you can use the sort filter with an arrow function in the arrow argument. For example, to order by name: {% for user in users|sort((a, b) => a.name <=> b.name) %} <td>{{ user.name }}</td> <td>{{ user.lastname}}</td> <td>{{ user.age}}</td> {% endfor %} Twig docs: https://twig.symfony.com/doc/2.x/filters/sort.html

Does Twig have a null coalesce operator?

The null-coalescing operator was formally introduced in Twig 1.24 (Jan. 25, 2016). * adding support for the ?? operator Which means it’s now possible to do this… {{ title ?? “Default Title” }} You can even chain them together, to check multiple variables until a valid non-null value is found. {{ var1 ?? var2 ?? … Read more