AzurePipelines icon indicating copy to clipboard operation
AzurePipelines copied to clipboard

Custom Handlebars Partials Support

Open corentinaltepe opened this issue 3 years ago • 1 comments

Azure DevOps Extensions

Generate Release Notes (Node Cross Platform)

Is your feature request related to a problem? Please describe.

Hello. Does the Generate Release Notes tool support importing custom Handlebars Partials? I see from documentation that we can import a custom handlebars helpers with the configuration keys customHandlebarsExtensionCode, and customHandlebarsExtensionFile.

I'd be interested in a similar feature enabling import of custom partials. That would greatly reduce code repetition in our templates.

Describe the solution you'd like

As far as I understand, I'd say add the 2 optional configuration keys:

  • customHandlebarsPartialsCode
  • customHandlebarsPartialsFile

In ReleaseNotesFunctions.ts, call to handlerbars.registerPartials(). I suspect we need to do something close to these lines.

Describe alternatives you've considered

Following documentation on using custom handlebars extensions, I tried importing my own handlebars and registering my custom partials myself. But that didn't work.

// customExtension.js
/** Handlebars extensions helping with generating TES' release notes. */
const handlebars = require("handlebars");
handlebars.registerPartials("mypartial", "{{my_custom_extension}}");

module.exports = {
  my_custom_extension() {
     // ...
  },
};

Console output:

##vso[task.debug]Attempting to load custom handlebars extension from xxxhandlebarsExtensions.js}
Loaded handlebars extension file
##vso[task.issue type=error;]Error Processing handlebars [Error: The partial mypartial could not be found]

Additional context

No response

corentinaltepe avatar Feb 17 '22 15:02 corentinaltepe

I can't see a reason not to add the feature looks useful. I am not sure when I will get around it, but it is on the backlog

rfennell avatar Feb 17 '22 16:02 rfennell