{% from "../../macros/i18n.njk" import govukPluralisedI18nAttributes %}
{% from "../textarea/macro.njk" import govukTextarea %}
{% from "../hint/macro.njk" import govukHint %}
{%- set hasNoLimit = (not params.maxwords and not params.maxlength) %}
{{ govukTextarea({
id: params.id,
name: params.name,
describedBy: params.id + '-info',
rows: params.rows,
spellcheck: params.spellcheck,
value: params.value,
formGroup: params.formGroup,
classes: 'govuk-js-character-count' + (' ' + params.classes if params.classes),
label: {
html: params.label.html,
text: params.label.text,
classes: params.label.classes,
isPageHeading: params.label.isPageHeading,
attributes: params.label.attributes,
for: params.id
},
hint: params.hint,
errorMessage: params.errorMessage,
attributes: params.attributes
}) }}
{%- set textareaDescriptionLength = params.maxwords or params.maxlength %}
{%- set textareaDescriptionText = params.textareaDescriptionText or 'You can enter up to %{count} ' + ('words' if params.maxwords else 'characters') %}
{#
If the limit is set in JavaScript, we won't be able to interpolate the message
until JavaScript, so we only set a text if the `maxlength` or `maxwords` options
were provided to the macro.
#}
{{ govukHint({
text: ((textareaDescriptionText) | replace('%{count}', textareaDescriptionLength) if not hasNoLimit),
id: params.id + '-info',
classes: 'govuk-character-count__message' + (' ' + params.countMessage.classes if params.countMessage.classes)
}) }}