I have a use to generate a random value and that h...
# general
p
I have a use to generate a random value and that has to be replaced in the multiple places, i was trying this {#assign 'myVar'}}{{capitalize (randomValue length=4 type='NUMERIC')}}{{/assign}}, but it is throwing error as "cause1": "wiremock.com.github.jknack.handlebars.HandlebarsException: inline@7121fcb0152: found: &apos;{{/&apos;, expected: &apos;<EOF>&apos;\n{{capitalize (randomValue length=4 type=&apos;NUMERIC&apos;)}}{{/assign}}\n is there any other way to get this done?
r
is there only a single opening brace (
{
) at the beginning of the assign invocation, like in your message?
why are you using the capitalize helper on a numeric value?
p
thanks @Rafe Arnold for pointing this out, it is not now throwing any exception, but not generating any value, where I am replacing myVar, it is printing myVar only and not any value
r
what does your full response template look like?
p
a simple one, { {{#assign 'myVar'}}{{capitalize (randomValue length=4 type='NUMERIC')}}{{/assign}} "token_type": "Bearer", "expires_in": myVar, "ext_expires_in": myVar, "access_token": "a string” }
r
you need to wrap
myVar
in curly braces like
{{myVar}}
. also if you want that template to emit valid json, you'll need to also wrap them in double quotes like
"{{myVar}}"
p
ah ok..got it, many thanks for rectifying it
r
no worries