<commit_before>{% set schema = bolt.data.components["@bolt-components-trigger"].schema %}

{% if enable_json_schema_validation %}
  {{ validate_data_schema(schema, _self) | raw }}
{% endif %}

{# Variables #}
{% set base_class = "c-bolt-trigger" %}
{% set this = init(schema) %}
{% set inner_attributes = create_attribute({}) %}

{% set tag = this.data.tag.value %}
{% set display = this.data.display.value %}
{% set cursor = this.data.cursor.value %}
{% set url = this.data.url.value %}
{% set target = this.data.target.value %}

{% if url %}
  {# If url is provided, automatically set tag to "a" #}
  {% set tag = "a" %}
  {% set inner_attributes = inner_attributes.setAttribute("href", url) %}

  {# only set target if url is provided #}
  {% if target %}
    {% set inner_attributes = inner_attributes.setAttribute("target", target) %}
  {% endif %}
{% endif %}

{% if tag == "button" %}
  {% set inner_attributes = inner_attributes.setAttribute("type", "button") %}
{% endif %}

{# Array of classes based on the defined + default props #}
{% set classes = [
  base_class,
  display and display != schema.properties.display.default ? "#{base_class}--#{display}" : "",
  cursor and cursor != schema.properties.cursor.default ? "#{base_class}--#{cursor}" : "",
] %}

{#
  Sort classes passed in via attributes into two groups:
  1. Those that should be applied to the inner tag (namely, "is-" and "has-" classes)
  2. Those that should be applied to the outer custom element (everything else EXCEPT c-bolt-* classes, which should never be passed in via attributes)
#}
{% set outer_classes = [] %}
{% set inner_classes = classes %}

{% for class in this.props.class %}
  {% if class starts with "is-" or class starts with "has-" %}
    {% set inner_classes = inner_classes|merge([class]) %}
  {% elseif class starts with "c-bolt-" == false %}
    {% set outer_classes = outer_classes|merge([class]) %}
  {% endif %}
{% endfor %}

{% set inner_attributes = inner_attributes.addClass(inner_classes) %}

{# Filter out attributes assigned above #}
{% set filtered_attributes = attributes | without("url") | without("href") | without("target") | without("class") %}

<bolt-trigger
  {% if outer_classes %} class="{{ outer_classes|join(' ') }}" {% endif %}
  {{ this.props|without("content")|without("class") }}
>
  <{{ tag }} {{ inner_attributes|without("on-click")|without("on-click-target") }} is="shadow-root">
    {{ content }}
  </{{ tag }}>
</bolt-trigger>
<commit_msg>fix: twig rendered class names<commit_after>{% set schema = bolt.data.components["@bolt-components-trigger"].schema %}

{% if enable_json_schema_validation %}
  {{ validate_data_schema(schema, _self) | raw }}
{% endif %}

{# Variables #}
{% set base_class = "c-bolt-trigger" %}
{% set this = init(schema) %}
{% set inner_attributes = create_attribute({}) %}

{% set tag = this.data.tag.value %}
{% set display = this.data.display.value %}
{% set cursor = this.data.cursor.value %}
{% set url = this.data.url.value %}
{% set target = this.data.target.value %}

{% if url %}
  {# If url is provided, automatically set tag to "a" #}
  {% set tag = "a" %}
  {% set inner_attributes = inner_attributes.setAttribute("href", url) %}

  {# only set target if url is provided #}
  {% if target %}
    {% set inner_attributes = inner_attributes.setAttribute("target", target) %}
  {% endif %}
{% endif %}

{% if tag == "button" %}
  {% set inner_attributes = inner_attributes.setAttribute("type", "button") %}
{% endif %}

{# Array of classes based on the defined + default props #}
{% set classes = [
  base_class,
  display and display != schema.properties.display.default ? "#{base_class}--display-#{display}" : "",
  cursor and cursor != schema.properties.cursor.default ? "#{base_class}--cursor-#{cursor}" : "",
] %}

{#
  Sort classes passed in via attributes into two groups:
  1. Those that should be applied to the inner tag (namely, "is-" and "has-" classes)
  2. Those that should be applied to the outer custom element (everything else EXCEPT c-bolt-* classes, which should never be passed in via attributes)
#}
{% set outer_classes = [] %}
{% set inner_classes = classes %}

{% for class in this.props.class %}
  {% if class starts with "is-" or class starts with "has-" %}
    {% set inner_classes = inner_classes|merge([class]) %}
  {% elseif class starts with "c-bolt-" == false %}
    {% set outer_classes = outer_classes|merge([class]) %}
  {% endif %}
{% endfor %}

{% set inner_attributes = inner_attributes.addClass(inner_classes) %}

{# Filter out attributes assigned above #}
{% set filtered_attributes = attributes | without("url") | without("href") | without("target") | without("class") %}

<bolt-trigger
  {% if outer_classes %} class="{{ outer_classes|join(' ') }}" {% endif %}
  {{ this.props|without("content")|without("class") }}
>
  <{{ tag }} {{ inner_attributes|without("on-click")|without("on-click-target") }} is="shadow-root">
    {{ content }}
  </{{ tag }}>
</bolt-trigger>

{'fraction_non_alphanumeric': 0.17832730197024527, 'fraction_numerical': 0.0008041817450743868, 'mean_word_length': 4.264550264550264, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2134556', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1484, 'n_words': 418}