Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass any attribute value type to markup (part 2) #42

Merged
merged 1 commit into from
May 20, 2022

Conversation

callinmullaney
Copy link
Contributor

@callinmullaney callinmullaney commented May 20, 2022

Summary

This PR fixes/implements the following bugs/features

  • Allow for non-string values to be passed to the add_attributes function within a Drupal twig template

Explain the motivation for making this change. What existing problem does the pull request solve?

  • It's sometimes necessary to pass an integer as a value for an attribute. In particular colspan for <td> elements. Currently, this value must be converted to a string BEFORE being passed to add_attributes()

Documentation Update (required)

  • none

How to review this PR

  • Edit any component and assign some test attrbitues to a variable: Note - we are passing an integer value directly to colspan and a boolean/string/integer multivalue via an array to data-test-attribute - The result of the boolean value should be 1
{% set test_attributes = test_attributes|default({
  'colspan': 3,
  'data-test-attribute': [TRUE, 'string', 123],
}) %}
  • Call the add_attributes function on an element within a Drupal twig template
<div {{ add_attributes(test_attributes) }}></div>
  • Inspect the markup and verify the above attributes are being properly rendered

Closing issues
emulsify-ds/emulsify-twig-extensions#4

Copy link
Contributor

@ModulesUnraveled ModulesUnraveled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's working. Let's cut a release and find out! :shipit:

@callinmullaney callinmullaney merged commit b34f6d0 into 2.x May 20, 2022
@callinmullaney callinmullaney mentioned this pull request May 20, 2022
@github-actions
Copy link

🎉 This PR is included in version 2.1.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants