简体   繁体   中英

Remove double quotes from a string in velocity template

The input is : var={cost=7022.61, marker=down, month=AUGUST, totalCost=17147.52}

The code is:

<table>
    <tr>
        <td>ESTIMATE FOR $var.month $var.cost</td>
    </tr>
    <tr>
        <td>Spent Last Month $var.totalCost</td>
    </tr>
</table>

output : ESTIMATE FOR "AUGUST" "7022.61"
Spent Last Month "17147.52"

Expected output : ESTIMATE FOR AUGUST 7022.61
Spent Last Month 17147.52

I had the same problem.

i solved in this way (velocity 1.7)

<table>
    <tr>
        <td>ESTIMATE FOR $!{var.month.replace('"',"")} $!{var.cost.replace('"',"")}</td>
    </tr>
    <tr>
        <td>Spent Last Month $!{var.totalCost.replace('"',"")}</td>
    </tr>
</table>

I hope I've given you all the answers about your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM