0

With Liquid markup, is it possible to strip out content between two placeholders.

For example let's say I have this content in a forum post:

This is my forum post. [[This is text I don't want to output in my forum post]]

Is there a way I could use a liquid markup filter to only display "This is my forum post, without the content in the brackets?

Something kind of like this?

{{ forum.post | strip-start: "[[" | strip-end: "]]" }}

user3513237
  • 995
  • 3
  • 9
  • 26

2 Answers2

1

There isn't a filter that does this but you can use multiple filters to get the content you want.

{% assign parts = forum.post | replace:'[[', [split] | replace:']]', [split] | split: '[split]' %}
{% assign removeMe = parts[1] %}

{{ forum.post | remove: removeMe }}
GeorgeButter
  • 2,521
  • 1
  • 29
  • 47
  • Bummer, this didn't work. I get this error: Liquid error: no implicit conversion of nil into String Liquid error: wrong argument type nil (expected Regexp) – user3513237 Jul 06 '17 at 23:37
0

Maybe not exactly what you are looking for but anything you put between using Liquid comment tags will not render.

{% comment %} Readme now because I'll be gone in the HTML ... {% endcomment %}

Jim Kohl
  • 46
  • 3