Question

Support liquid strip_html

  • 22 May 2019
  • 4 replies
  • 357 views

We have some text fields that have HTML in them and need to strip out the tags for display inside of Looker.


Liquid supports “val | strip_html” but it doesn’t seem that Looker does.


4 replies

Userlevel 7
Badge +1

This is something that we’ll work on fixing up with our liquid implementation, thanks Devin!


In the meantime, @sam concocted a workaround to strip html out using some complex liquid.


html: {% assign words =  value | escape | replace: "<", "µ" |  replace: ">", "µ" | split: 'µ'  %}
{% assign i = 0 %}
{% for word in words %}
{% assign m = i | modulo: 2 %}
{% if m == 0 %}
{{ word }}
{% endif %}
{% assign i = i | plus: 1 %}
{% endfor %}
;;

All credit to Sam!

Did implementing strip_html ever make the cut? It would be really nice in fields that contain HTML to be able to choose between the current behavior where it’s escaped, and stripping it to highlight readable text…

Hi @jayshao I’ve just tested and using  the following format in the html parameter is working if you’d like to test out:

{{  value  | strip_html }}

 

Hi @jayshao I’ve just tested and using  the following format in the html parameter is working if you’d like to test out:

{{  value  | strip_html }}

 

Doesn’t seem to work for me. Any news on that?

Reply