Bootstrap FreeKB - Jinja - Remove whitespace using trim
Jinja - Remove whitespace using trim

Updated:   |  Jinja articles

trim is a Jinja2 filter used to remove whitespace from the left and right sides of a string. For example, let's say you have the following.

"{{ '     hello world     ' }}"

 

This should output the following, where we can see whitespace before and after hello world.

"     hello world     "

 

trim can be used to remove the whitespace from the left and right sides of hello world.

"{{ '     hello world     ' | trim }}"

 

Which should return the following.

"hello world"

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 3fe319 in the box below so that we can be sure you are a human.