-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Add registration of custom handlebar helpers which can be added in custom template #347
Comments
The custom template is there for anyone to use and change as they like, you can remove all the template code and start from nothing if that's what you need. You can also pull in any CDNs or create custom JS in the file - it's completely up to you. The data that's coming from the Newman object is going to be the same and in the same structure though. There is no magic happening in the reporter :D I have a series of custom handlebar helpers in the https://github.com/DannyDainton/newman-reporter-htmlextra/blob/main/lib/index.js file which can be used in the final report - you will see some of them in the template. These are used in conjunction with the various flags to remove specific pieces of data. I've also brought in https://github.com/helpers/handlebars-helpers which gives you a further 130+ helpers to use in the template too shape the data how you like. |
Hi Danny, Thanks for your reply. Yes, this is exactly what I am trying to do - to create a report from scratch. That's why first I got the output JSON from Newman and tried to create my report using handlebars. It worked well. But when I used my template with newman and htmlextra, my handlebars stopped working. Can you show me an example of how I can use index.js with my template and handlebars? Can I have access to your aggregations or handlebars from index.js? Sorry, I am still trying to figure out how it all works together, so please bear with me. |
The index.js file is part of the internal reporter code and it's the file that basically creates the final report based on the default template, all the logic to hide certain data from the final report is handled there. https://github.com/DannyDainton/newman-reporter-htmlextra/blob/main/lib/index.js Your custom template is passed in at runtime and the reporter knows that you want to use that and not the default one. I'm not even going to pretend to know how to add helpers that solely live in the custom template, I'm not sure it is would even work as the compiling of the template happening in the report code and not in the custom template. 🤔 You could also checkout the project code and add your helper to the index.js file and run it against your custom template, https://github.com/DannyDainton/newman-reporter-htmlextra#contributing-to-the-project If it's a generic one that others can use I will include it but if it's super specific to your context, I'm not really wanting to add those in. It's a general-purpose reporter so I don't want to clutter it with single usecase features. |
I see. To modify your reporter is not a solution for me since this is not my own local playing with the reporter. Maybe I am still missing something with existing helpers? I see this part in your template, which looks similar to what I want to do:
If (key.startsWith("PROJ")) |
So, my main issue is that I cannot merge 2 lists using Handlebars like below: {{#each aggregations }} As a workaround, I do it in 2 separate lists and prepend globals values as the first row to assertions. |
Hey @PaulSh84 I'm not sure what to do with this open request, it isn't something that I'm going to be doing. I'm going to close it but happy to reopen if you feel it should still be open. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Is your feature request related to a problem? Please describe.
I am using htmlextra helpers to populate data in my custom report. I dump specific data related to each request like API resource id created with each request and jira ID(for reference) in globals/values as an array. Each request has its own list of assertions. So I am trying to create a list of objects in format like below:
[ { globals.values.key: "jira id", globals.values.value: "resource Id", assertions:[] } ]
The issue is that I can get the list of assertions, but I don't have a helper to join them with corresponding global values.
Describe the solution you'd like
I am not sure htmlextra report needs this kind of helper. Since there is a possibility to create a custom template, I think, it could be a good idea to be able to register custom helpers inside custom .hbs file.
Describe alternatives you've considered
I would be happy if there were any alternative to fix my issue
Additional context
The text was updated successfully, but these errors were encountered: