Skip to content
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

Consider making more components callable #941

Closed
frankieroberto opened this issue Aug 3, 2018 · 2 comments · Fixed by #2734
Closed

Consider making more components callable #941

frankieroberto opened this issue Aug 3, 2018 · 2 comments · Fixed by #2734
Assignees
Labels
details feature request User requests a new feature firebreak0722 From Firebreak in July 2022 nunjucks
Milestone

Comments

@frankieroberto
Copy link
Contributor

frankieroberto commented Aug 3, 2018

It feels fairly common to include html (eg multiple paragraphs), and possibly even other components, with a Details component, or other components such as Panel or Inset Text.

To this end, it'd be nice to make these component callable, so you could do this:

{% call govukDetails({summaryText: 'Test'}) -%}
  <p>hello</p>
  <p>world</p>
{% endcall %}

as an alternative to this:

{% set detailsHtml %}
  <p>hello</p>
  <p>world</p>
{% endset %}

{% call govukDetails({summaryText: 'Test', html: detailsHtml}) -%}
@vanitabarrett
Copy link
Contributor

This came up again today, suggested by a new user #2299

GDS components support passing HTML content inline or via a variable with separate set block. Often the structure of this content means that passing HTML content inline is messy or impossible. This results in many set blocks that are disconnected from their components, which is difficult to read.

A solution to this would be to support the caller() block within GDS macros. From Nunjucks documentation: A call block enables you to call a macro with all the text inside the tag. This is helpful if you want to pass a lot of content into a macro. The content is available inside the macro as caller().

@querkmachine
Copy link
Member

Did some light investigation on this today. It does strike me as a weird omission, especially as implementing it would be a fairly simple, non-breaking enhancement.

I consider these to be good candidates for caller()-ification:

  • Cookie banner: main content
  • Details: main content
  • Error summary: description HTML
  • Inset text: main content
  • Notification banner: main content
  • Panel: main content
  • Warning text: main content

@Astrs2004 Astrs2004 added the firebreak0722 From Firebreak in July 2022 label Jul 20, 2022
@querkmachine querkmachine linked a pull request Jul 26, 2022 that will close this issue
5 tasks
@querkmachine querkmachine added this to the v4.3.0 milestone Jul 27, 2022
@querkmachine querkmachine self-assigned this Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
details feature request User requests a new feature firebreak0722 From Firebreak in July 2022 nunjucks
Projects
Development

Successfully merging a pull request may close this issue.

9 participants