Skip to content

Commit e713cae

Browse files
versionsixlxhunter
authored andcommitted
Add wordwrap example
lookup a string and later on use the wordwrap jinja2 filter to split it. Test is locally: ```python ansible all -i localhost, --connection=local -m debug -a "msg={{lookup('vars','my_verylong_var') | wordwrap(width=3, break_long_words=True, wrapstring=None)}}" -e "my_verylong_var=123456789" ```
1 parent dc01707 commit e713cae

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/jinja_functions.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,9 @@ Count the words in that string.
751751
Return a copy of the string passed to the filter wrapped after 79 characters. You can override this default using the first parameter. If you set the second parameter to false Jinja will not split words apart if they are longer than width. By default, the newlines will be the default newlines for the environment, but this can be changed using the wrapstring keyword argument.
752752

753753
```python
754-
# todo: supply example?
754+
my_verylong_var: 123456789
755+
{{lookup('vars','my_verylong_var') | wordwrap(width=3, break_long_words=True, wrapstring=None)}}
756+
# => 123\n456\n789
755757
```
756758

757759
_New in version 2.7: Added support for the wrapstring parameter._

0 commit comments

Comments
 (0)