Hi everyone!
Quite new in Ghost theme development, I am facing a problem which I cannot fin a way to solve.
I want to test a string against either a regex or using filter operators ~^
, ~
, or ~$
to check if it contains, starts or ends with a specific string.
For now, I cannot find a way and my only workaround is to match on the entire string but it prevents me from changing the string in the Ghost back office
<ul class="nav">
{{#foreach navigation}}
{{!-- Attibutes label, url, current, slug --}}
<li class="nav-{{slug}}{{#if current}} nav-current{{/if}}"><a href="{{url absolute="true"}}">{{label}}</a></li>
{{#match label "Veggies[has_child]"}}
{{#get "tags" filter="slug:~^'veggies" limit="4"}}
{{#foreach tags}}
<li class="nav-{{slug}}"><a href="{{url}}">{{name}}[subitem]</a></li>
{{/foreach}}
{{/get}}
{{/match}}
{{#match label "Water[has_child]"}}
{{#get "tags" filter="slug:~^'water'" limit="4"}}
{{#foreach tags}}
<li class="nav-{{slug}}"><a href="{{url}}">{{name}}[subitem]</a></li>
{{/foreach}}
{{/get}}
{{/match}}
{{/foreach}}
</ul>
</div>
Is there a way to achieve this string comparison using either a if
or a match
?
Thanks a lot in advance and thanks to all the Ghost team! The product is awesome!