Search code examples
springspring-mvcthymeleafandroid-paygoogle-pay

How to set a placeholder into a non-Thymeleaf parameter?


I am trying to implement SaveToAndroidPay button on my html page, created with Thymeleaf. I have a parameter in context specified from Spring's back-end called jwt.

<g:savetoandroidpay jwt="<<<HERE>>>" size="small" theme="light" ></g:savetoandroidpay>

How can I set this parameter into non-thymeleaf attribute (jwt)? Both ${jwt} and [[${jwt}]] are not working.


Solution

  • In Thymeleaf 3, you can simply prefix the attribute with th:. So:

    <g:savetoandroidpay th:jwt="${jwt}" size="small" theme="light" ></g:savetoandroidpay>
    

    If you're using Thymeleaf 2 (this works in Thymeleaf 3 as well), you can also just use th:attr, as was commented:

    <g:savetoandroidpay th:attr="jtw = ${jwt}" size="small" theme="light" ></g:savetoandroidpay>