Using this as ref doc <https://docs.wiremock.io/re...
# help
r
Using this as ref doc https://docs.wiremock.io/response-templating/dates-and-times/ for the example
Copy code
{{now offset='3 days'}}
If I need to pick the value from a variable that is defined earlier , instead of a fixed number ( 3 in this example) , what are the ways to do that. Further, if this variable needs to coming from a loop index - where index is changing with each iteration in the loop, is that possible.
t
You can use the
concat
helper to build the offset string e.g.
Copy code
{{now offset=(concat request.query.offsetDays.0 ' days)}}
r
great thanks. I will try to use this.
What is the right ref doc for such functions so that I don't have to borrow your valuable time for these and other helper functions. Is it handlebar js ?
Copy code
{{now offset=(concat request.query.offsetDays.0 ' days)}}
the above syntax seems to have some issues
Copy code
12:30: found: 'days'', expected: ')'
t
This is the implementation we use: https://github.com/jknack/handlebars.java
Apologies @Rahul Agrawal, I’ve misled you here. Seems we’re not loading the concat helper at the moment so it’s not available. You can use
assign
for the same purpose, however:
Copy code
{{#assign 'offset'}}{{request.query.offsetDays}} days{{/assign}}
{{now offset=offset}}
👍 1
r
Thanks for the help with the above code. Don't worry , your did not mislead me . It was blessing in disguise. Forced me try other options and read more. the above expression seems a very elegant approach and will hep me for few other things also. Rarely seen the founders paying so much attention to each query from end users to help them. This is another thing to learn from you @Tom. 👏
t
No problem, and thanks for the kind feedback!
🙏 1