Skip to content

Instantly share code, notes, and snippets.

@jlabs
Last active June 23, 2021 10:27
Show Gist options
  • Save jlabs/1cc2df2ebadc9f60ea8239ab342c1292 to your computer and use it in GitHub Desktop.
Save jlabs/1cc2df2ebadc9f60ea8239ab342c1292 to your computer and use it in GitHub Desktop.
Padding of text in Twig
{#
display the number 9 with 2 0's in front of it
%'_3s would display the number 9 with 2 _ in front
%'%10s with format("123") would display 123 with 7 % in fron of it
% 3s would show 9 and 2 spaces in front
%'_-3s would have 9 then 2 _ after it
%'x-3s would have 2 x's after
#}
{{ "%'03s"|format("9") }} = 009
{{ "%'--10s"|format("abc") }} = abc-------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment