Sha256: ed796d585411e31b88fc0de237fecd92fca014048f416e32eed3a3f41469a8fc

Contents?: true

Size: 1.48 KB

Versions: 42

Compression:

Stored size: 1.48 KB

Contents

{# Determine type of element to use, if not explicitly set -#}

{% if params.element %}
  {% set element = params.element | lower %}
{% else %}
  {% if params.href %}
    {% set element = 'a' %}
  {% else %}
    {% set element = 'button' %}
  {% endif %}
{% endif %}

{#- Define common attributes that we can use across all element types #}

{%- set commonAttributes %} class="govuk-button{% if params.classes %} {{ params.classes }}{% endif %}{% if params.disabled %} govuk-button--disabled{% endif %}"{% for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}{% endset %}

{#- Define common attributes we can use for both button and input types #}

{%- set buttonAttributes %}{% if params.name %} name="{{ params.name }}"{% endif %} type="{{ params.type if params.type else 'submit' }}"{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% endset %}

{#- Actually create a button... or a link! #}

{%- if element == 'a' %}
<a href="{{ params.href if params.href else '#' }}" role="button" {{- commonAttributes | safe }}>
  {{ params.html | safe if params.html else params.text }}
</a>

{%- elseif element == 'button' %}
<button {%- if params.value %} value="{{ params.value }}"{% endif %} {{- buttonAttributes | safe }} {{- commonAttributes | safe }}>
  {{ params.html | safe if params.html else params.text }}
</button>

{%- elseif element == 'input' %}
<input value="{{ params.text }}" {{- buttonAttributes | safe }} {{- commonAttributes | safe }}>
{%- endif %}

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
govuk_publishing_components-12.0.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-11.2.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-11.1.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-11.0.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-10.2.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-10.1.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-10.0.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.28.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.27.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.26.1 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.26.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.25.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.24.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.23.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.22.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.21.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.20.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.19.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.18.0 node_modules/govuk-frontend/components/button/template.njk
govuk_publishing_components-9.17.1 node_modules/govuk-frontend/components/button/template.njk