Decluttering card - use of if statement

Hi,
I’m just trying a simple example of the decluttering template but I have some problems using the if statement. Can someone please point me to the correct behavior.
This is the simple/test template code

decluttering_templates:
  test:
    card:
      type: custom:button-card
      icon: >
        [[[ return (variables.usd === true || variables.usd === 'true') ?
        'mdi:cellphone' : 'mdi:airplane'; ]]]

and this is the implementation

type: custom:decluttering-card
template: test
variables:
  - usd: true

no matter if I use true or false , there is always a plane shown. I also tried with single or double quotes around the value of usd. Could someone please provide a simple example

within these [[[ ... ]]] brackets, you’re in javascript-land so you need to use javascript. Try this instead:

   [[[
     if (states['[[usd]]'].state == 'true') return 'mdi:cellphone';
     else return 'mdi:airplane';
   ]]]

…I’m not at my desktop so haven’t checked this for typos etc

Thanks it is working now, I only have to tweak it a little bit as I’m passing true or false and not sensor, So I couldn’t use states

No sense to use a decluttering card for button-card since it has native templates.

This was just a small example, to understand the working of it. I have a more complex one where I’m struggeling with… I’m creating my own stock card

This is a part of my stock card (the easy part) but I’m having troubles to use the var usd (true or false) in my template. I have a sensor with the exchange rate and I want to use that sensor in the part of the “primary” where the value of my stock is calculated. If usd is false no exchange rate (or 1) should be used to muliply is usd is true the sensor exchange rate should be used. Could someone please help me out with this if this is a snippet of my template

decluttering_templates:
  stock_card:
    variables:
      - stock_sensor
      - aandeel_sensor
      - waarde_sensor
      - usd
    card:
      type: custom:vertical-stack-in-card
      cards:
        - type: grid
          columns: 2
          square: false
          cards:
            - type: custom:mushroom-template-card
              primary: '{{ state_attr(''[[stock_sensor]]'', ''friendly_name'') }} €'
              entity: '[[stock_sensor]]'
              icon: ''
              card_mod:
                style:
                  mushroom-state-info$: |
                    .container {
                      --card-primary-font-size: 20px;
                      --primary-text-color: #EA906C;
                      font-weight: bold;
                    }
                  .: |
                    ha-card {
                      background-color: #f2f2f2;
                      border: none;
                    }
            - type: custom:mushroom-template-card
              primary: >-
                {{ (state_attr('[[stock_sensor]]', 'regularMarketPrice') |
                float) * (state_attr('[[aandeel_sensor]]', 'aantal') | float) |
                round(2) }} €
              entity: '[[stock_sensor]]'
              icon: ''
              alignment: end
              card_mod:
                style:
                  mushroom-state-info$: |
                    .container {
                      --card-primary-font-size: 20px;
                      justify-content: flex-end;
                      text-align: right;
                    }
                  .: |
                    ha-card {
                      background-color: #f2f2f2;
                      border: none;
                    }