mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
[Question] Dates in response templates #330
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Narcalen on GitHub (Jan 25, 2021).
Is it possible to add formatted dates to response templates? e.g. I would like to do smth like this:
Where now is current datetime, not data extracted from request
@StefH commented on GitHub (Jan 25, 2021):
Hello @Narcalen
This is not yet supported in WireMock.Net but this could be added to Handlebars.Net.Helpers
I will take a look if it can be added there.
@StefH commented on GitHub (Jan 26, 2021):
@Narcalen
I'm looking at the code from Handlebars.Net/Helpers and in this case, the string to use would be like:
Would be work for you?
@StefH commented on GitHub (Jan 27, 2021):
Or another possible solution will be:
@Narcalen commented on GitHub (Jan 27, 2021):
Thank you for the response! I have tried the second option and I am getting the following response: Template references a helper that is not registered. Could not find helper 'Now'
Is it possible to register additional handlebar helpers?
@StefH commented on GitHub (Jan 27, 2021):
Sorry for the confusion I caused.
This new functionality is now present in Handlebars.Net.Helpers however not yet used by WireMock.Net
I'm working in that and I keep you informed.
@StefH commented on GitHub (Jan 30, 2021):
@Narcalen
I've added functionality to Handlebars.Net.Helpers and these are used in WireMock.Net
Please try preview version
WireMock.Net.1.4.3-ci-14593from MyGet.@Narcalen commented on GitHub (Feb 3, 2021):
@StefH
Thank you for the update
I have updated to WireMock.Net.1.4.3-ci-14593 and tried the following options:
"{{Format (Now) \"yyyy-MM-dd\"}}""{{Now \"yyyy-MM-dd\"}}"For both options, I received the following error:
{ "Status": "Template references a helper that cannot be resolved. Helper 'Format'" }Moreover, I have received the same errors for other helpers, e.g.:
{ "Status": "Template references a helper that cannot be resolved. Helper 'Random'" }Could you please suggest if I am missing anything?
@StefH commented on GitHub (Feb 4, 2021):
Can you share your example project?
@Narcalen commented on GitHub (Feb 8, 2021):
https://github.com/Narcalen/example-wiremock-net
This mapping works fine with version 1.4.3 and returns
Template references a helper that cannot be resolvederror with 1.4.3-ci-14626@StefH commented on GitHub (Feb 8, 2021):
This should work:
Use exact version 1.4.3-ci-14635
@Narcalen commented on GitHub (Feb 9, 2021):
@StefH this version works fine for me. Thanks!
@StefH commented on GitHub (Feb 9, 2021):
great!
You can expect a new 1.4.4 in some time