'Run time variable is not resolved inside style element

I am trying to provide the background image to a div by creating a variable in sightly.

<sly data-sly-test.file="${properties.image}" />
<div style="background: url(${file @ context='styleToken'});"></div>

it does not work.

 <div style="background: url();">
aem


Solution 1:[1]

Try <div style="background-image:url('${properties.file@ context='styleString'}');" >

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vinit Pillai