Using MatchString go function

Hy,

I am pretty new with everything related to creating a website. The last few weeks I have learned a lot and made my first one with the help of Hugo. So, thanks a lot for all the effort put in this wonderful program by the community.

There are still many small things I have trouble to do. I would like to ask your help for one of these things. I explain below what I did. The question follows.

In this website I have a registration from, for which I receive per mail data in the basic following form:

    name: Euler
    firstName: Leonard
    attendance: monday,tuesday,friday
    ...

In order to treat this data, I copy past the content of this email in my data folder in a file participants/participant1.yaml.
Then I can use this data to create my list of participants using {{ range .Site.Data.participants }} and I can print their name in a table (as you can see in the website).

Now I would like to use the information which is in the field “attendance”. What I would like to do is to use a function which tell me if “monday” appears or not in the string stored in the attendance field.

I found out that there is a go function called MatchString which does this job but I did not manage to use it (among other things I tried {{ MatchString "monday" .attendance }}). My question is can I use this function? and how?

Best regards,
Gilles

Did you try https://gohugo.io/functions/in/#readout

2 Likes

Thank you! It works perfectly. :grinning:

1 Like