Knowledge Drop

Formatting text on multiple lines

Userlevel 5

Last tested: Nov 20, 2018

You can use html and some liquid to format text to appear on multiple lines. This can be useful if you have a dimension that has really long strings as values and you want to see the text on multiple lines in a single value visualization. Note, not all visualization types support this. Some ignore the html formatting.

Here is some code that will put a new line after every two words:

html: {% assign words = {{value}} | split: ' ' %} {% assign numwords = 0 %} {% for word in words %} {{ word }} {% assign numwords = numwords | plus: 1 %} {% assign mod = numwords | modulo: 2 %} {% if mod == 0 %} <br> {% endif %} {% endfor %} ;;


This html parameter is to be included in the definition of the dimension/ measure.

You can increase the number of words that appear on a line, by changing the 'modulo: 2' portion to 'modulo: n'


This content is subject to limited support.                



0 replies

Be the first to reply!