torchbox/django-pattern-library

Pass context to template tag override

tbrlpld opened this issue · 0 comments

Is your proposal related to a problem?

When overriding a template tag you have the option to render another template in its place.

Currently, only the existing template context (from the yaml file) of that template will be taken into account.
It would be nice to have the option to pass context overrides to the template.

Describe the solution you'd like

E.g. in a template override like this:

tags:
  include_block:
    tl with size="2xl" heading_level=sub_heading_level:
      template_name: "atoms/teaser-link/teaser-link.html"

I would love to be able to do something like this:

tags:
  include_block:
    tl with size="2xl" heading_level=sub_heading_level:
      template_name: "atoms/teaser-link/teaser-link.html"
      context_override: 
        size: "2xl"
        heading: "Overrding the heading form the template context yaml"

Describe alternatives you've considered

An alternative is to create specific variants of the template I really want to use. That has the tendency to clutter the template directly.