Search code examples
freemarker

Wrap all the strings with single quotas


Let's assume that my template is like a following

string1=${obj.firstString}
string2=${obj.secondString}
number1=${obj.firstNumber}

I'm looking for some automatic way to wrap all my string parameters with single quotas? The expected output is

string1='A'
string2='B'
number1=42

I understand that I can write string1=${"'" + obj.firstString + "'"} , but maybe there is some more conventional way for this requirement...

Thanks a lot!


Solution

  • I would just do this:

    string1='${obj.firstString}'
    string2='${obj.secondString}'
    number1=${obj.firstNumber}
    

    It's a template language, so the basic idea is to make your program look similar to its own output.