bake icon indicating copy to clipboard operation
bake copied to clipboard

Custom helpers for twig templates

Open skie opened this issue 4 years ago • 2 comments

Custom helpers for twig templates could be needed when user want to add more logic to templates, which is not possible to implement in twig templates.

We can consider two options:

  1. Find way to pass custom helper list in TemplateRenderer layer.
  2. Allow to define custom TemplateRenderer class which loaded in all commands.

Lets discuss what is the best way to add this feature.

skie avatar Nov 04 '20 17:11 skie

We could add a BakeCommand::templateRenderer() which returns the renderer instance so people can use $this->templateRenderer()->viewBuilder() in execute() (or any other method) to setup the view builder.

ADmad avatar Nov 04 '20 17:11 ADmad

You can handle the bake init event to add helpers, but it doesn't let you customize the view builder before creating.

othercorey avatar Nov 04 '20 18:11 othercorey