CSS Flask Basics Character Builder Items

If statement

Hi,

I am struggling to understand what is going on in this line of code:

{% if saves.get(category) == choice %} checked {% endif %}

Why would the if statement check if what has been saved is equal to choice? In that regard, how do we make sure that it will check the item that we have selected and not other?

Thanks for your help?

1 Answer

Daniel Schirmer
Daniel Schirmer
4,364 Points

It's not totally clear, because I couldn't see the code for the Update button, but the Update button should save the item that is clicked into the cookie. saves.get(category). So I think it would go like:

  1. User clicks an item picture in a category and then clicks Update
  2. Update button saves the item name/category into a cookie (via the save function with url redirects)
  3. The if statement in question checks the cookie for a match {'shorts': 'yellow'} and makes "checked" the value from the key-value pair in the cookie.