Askama Parse Error when passing as reference with &-icon

Hello

I have a list of strings I pass to my Askama template. Then I try to check if a specific value exists in that list, if it does add checked to the HTML checkbox.

Code:

<div><input type="checkbox" value="sushi" name="restaurant_categories" {% if restaurant_categories.contains(&("sushi".to_string())) %}checked{% endif %}> Sushi</div>

It gives the following Askama-error:

error: problems parsing template source at row 118, column 68 near:
       "(&(\"sushi\".to_string())) %}\n

Askama can't parse it for some reason. Why?

Solved it by removing the &-icon. Seems like Askama somehow interprets values between brackets as a reference...

<div><input type="checkbox" value="sushi" name="restaurant_categories" {% if restaurant_categories.contains(("sushi".to_string())) %}checked{% endif %}> Sushi</div>

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.