Skip to content

Commit

Permalink
Update DS components to ensure compatibility with Jinja (#3380)
Browse files Browse the repository at this point in the history
  • Loading branch information
precious-onyenaucheya-ons authored Oct 8, 2024
1 parent 11cda71 commit a8522e7
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/components/details/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
{% if params.headingAttributes %}{% for attribute, value in (params.headingAttributes.items() if params.headingAttributes is mapping and params.headingAttributes.items else params.headingAttributes) %}{{ ' ' }}{{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}
>
{% set titleTag = params.headingLevel | default(2) %}
{% set openingTag = "<h" + titleTag %}
{% set closingTag = "</h" + titleTag + ">" %}
{% set openingTag = "<h" ~ titleTag %}
{% set closingTag = "</h" ~ titleTag ~ ">" %}
{{ openingTag | safe }}
class="ons-details__title">{{ params.title }}{{ closingTag | safe }}
<span class="ons-details__icon">
Expand Down
4 changes: 2 additions & 2 deletions src/components/document-list/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
>
{% for document in params.documents %}
{% set titleTag = params.headingLevel | default(2) %}
{% set openingTag = "<h" + titleTag %}
{% set closingTag = "</h" + titleTag + ">" %}
{% set openingTag = "<h" ~ titleTag %}
{% set closingTag = "</h" ~ titleTag ~ ">" %}
{% set documentItem %}
{% if document.thumbnail %}
<div
Expand Down
8 changes: 4 additions & 4 deletions src/components/panel/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@

{% if params.title %}
{% if params.variant == 'error' %}
{% set defaultTitleTag = "h" + 2 %}
{% set defaultTitleTag = "h" ~ 2 %}
{% else %}
{% set defaultTitleTag = "div" %}
{% endif %}
{% set headingLevel = "h" + params.headingLevel if params.headingLevel else undefined %}
{% set headingLevel = "h" ~ params.headingLevel if params.headingLevel else undefined %}
{% set titleTag = headingLevel | default(defaultTitleTag) %}
{% set openingTag = "<" + titleTag %}
{% set closingTag = "</" + titleTag + ">" %}
{% set openingTag = "<" ~ titleTag %}
{% set closingTag = "</" ~ titleTag ~ ">" %}
<div class="ons-panel__header">
{{ openingTag | safe }} id="alert"{% if params.variant %}data-qa="{{ params.variant }}-header"{% endif %}
class="ons-panel__title ons-u-fs-r--b">{{ params.title | safe }}{{ closingTag | safe }}
Expand Down
4 changes: 2 additions & 2 deletions src/components/share-page/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

{% if params.title %}
{% set titleTag = params.headingLevel | default(2) %}
{% set openingTag = "<h" + titleTag %}
{% set closingTag = "</h" + titleTag + ">" %}
{% set openingTag = "<h" ~ titleTag %}
{% set closingTag = "</h" ~ titleTag ~ ">" %}
{{ openingTag | safe }}
class="ons-u-fs-r--b ons-u-mb-xs">{{ params.title }}{{ closingTag | safe }}
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions src/components/summary/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
{% for group in summary.groups %}
<div {% if group.id %}id="{{ group.id }}"{% endif %} class="ons-summary__group{{ variantClasses }}">
{% if group.title %}
{% set openingHeadingTag = "<h" + headingLevel %}
{% set closingHeadingTag = "</h" + headingLevel + ">" %}
{% set openingHeadingTag = "<h" ~ headingLevel %}
{% set closingHeadingTag = "</h" ~ headingLevel ~ ">" %}
{{ openingHeadingTag | safe }}
class="ons-summary__group-title">{{ group.title }}{{ closingHeadingTag | safe }}
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions src/components/tabs/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

<section class="{{ classes }}" {% if params.noInitialActiveTab %}data-no-initial-active-tab="true"{% endif %}>
{% set titleTag = params.headingLevel | default(2) %}
{% set openingTag = "<h" + titleTag %}
{% set closingTag = "</h" + titleTag + ">" %}
{% set openingTag = "<h" ~ titleTag %}
{% set closingTag = "</h" ~ titleTag ~ ">" %}
{{ openingTag | safe }}
class="ons-tabs__title ons-u-fs-r--b
ons-u-mt-no{{ ' ' + params.titleClasses if params.titleClasses else '' }}">{{ params.title }}{{ closingTag | safe }}
Expand Down
4 changes: 2 additions & 2 deletions src/components/timeline/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

<div class="ons-timeline{{ ' ' + params.classes if params.classes else '' }}">
{% set titleTag = params.headingLevel | default(2) %}
{% set openingTag = "<h" + titleTag %}
{% set closingTag = "</h" + titleTag + ">" %}
{% set openingTag = "<h" ~ titleTag %}
{% set closingTag = "</h" ~ titleTag ~ ">" %}
{% for item in params.timelineItems %}
<div class="ons-timeline__item">
{{ openingTag | safe }} class="ons-timeline__heading">{{ item.heading }}{{ closingTag | safe }}
Expand Down

0 comments on commit a8522e7

Please sign in to comment.