List filters do not match exact value
miltondp opened this issue · 3 comments
Checks
- I have searched the docs, existing issues, and existing discussions for answers first.
Link to your website repo
https://github.com/pivlab/pivlab-website
Version of Lab Website Template you are using
1.2.0
Description
I created this PR on my lab's website repo to change the order in which lab members are shown. I found that the filters
parameter of the List component does not match values exactly; instead, it looks for substrings. For instance, if you have two roles in _data/types.yaml
named programmer
and programmer-lab
, a filter with role: programmer
will match both.
This could be fixed by changing the documentation of the List component.
This is how I fixed the bug (see $
at the end of role
in second line):
{% include list.html data="members" component="portrait" filters="role: programmer-lab, group: " %}
{% include list.html data="members" component="portrait" filters="role: programmer$, group: " %}
I will update the documentation about this. Originally I planned to have plain strings be exact matches but at some point I removed that and forgot to update the documentation.
Unfortunately, the filter always receives a plain string (because it comes from liquid/jekyll which doesn't have a special type for regex) and then has to decide whether to treat it as an exact match or regex somehow. I guess I could try to check for if the string contains special regex characters like +
or *
, but that could be brittle. It's probably best to just always treat it like a regex, and thus a plain string like "lab" would just be a partial match, and you'd have to do ^lab$
for an exact match.
Fixed with greenelab/lab-website-template-docs@0d93949