Module: GovukDesignSystem::DetailsHelper
- Defined in:
- app/helpers/govuk_design_system/details_helper.rb
Instance Method Summary collapse
-
#govukDetails(summaryText: nil, summaryHtml: nil, text: nil, html: nil, id: nil, open: nil, classes: "", attributes: {}) ⇒ Object
Generates the HTML for the [Details component](design-system.service.gov.uk/components/details/) from the GOV.UK Design System.
Instance Method Details
#govukDetails(summaryText: nil, summaryHtml: nil, text: nil, html: nil, id: nil, open: nil, classes: "", attributes: {}) ⇒ Object
Generates the HTML for the [Details component](design-system.service.gov.uk/components/details/) from the GOV.UK Design System.
The method name and parameters are camelCased to follow the convention of the Nunjucks macros from the GOV.UK Design System, to make it easier to copy and paste templates from the Prototyping Kit.
Implementation based on github.com/alphagov/govuk-frontend/blob/master/src/govuk/components/details/
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/govuk_design_system/details_helper.rb', line 14 def govukDetails(summaryText: nil, summaryHtml: nil, text: nil, html: nil, id: nil, open: nil, classes: "", attributes: {}) attributes.merge!("class" => class_names("govuk-details", classes), id: id, "data-module" => "govuk-details") attributes["open"] = "open" if open content_tag("details", attributes) do summary = content_tag("summary", class: "govuk-details__summary") do content_tag("span", class: "govuk-details__summary-text") do summaryHtml || summaryText end end content = content_tag("div", class: "govuk-details__text") do html || text || yield end summary + content end end |