כיצד להפנות לתמונה לפי שם שצוין בהגדרה?

I believe you can use the setting directly using interpolation.

background: transparent URL("$#{$hat_type}") top left no-repeat;