-
Notifications
You must be signed in to change notification settings - Fork 5
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 #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got a question for you.
src/AddAttributesTwigExtension.php
Outdated
else { | ||
continue; | ||
$value = [$value]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@callinmullaney I am thinking this is a little too open, it seems like your use case (original question) is to support integers. Should we not have another case to handle integers (convert them to a string)?
Currently this is what I am seeing we are processing:
- Arrays (flat) - technically nested arrays would just not work
- (object) Attribute
- Strings
- Default - Do nothing
I think this would read easier if we were using a switch statement here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ccjjmartin I updated this PR to use a switch statement like you suggested. The original scope of this issue was to handle passing integers type values but with the changes I made we can also handle boolean.
That being said, while nested arrays and objects would also be a nice thing to process if passed to add_atributes()
I think it's a bit out of scope for the original issue. The switch statement framework established here would be a good jumping off point for another branch to add support.
Can you take a quick look at this and confirm the testing criteria above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@callinmullaney Code looks good, functional works with test described 👍
🎉 This PR is included in version 2.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
This PR fixes/implements the following bugs/features
add_attributes
function within a Drupal twig templateExplain the motivation for making this change. What existing problem does the pull request solve?
colspan
for<td>
elements. Currently, this value must be converted to a string BEFORE being passed toadd_attributes()
Documentation Update (required)
How to review this PR
colspan
and a boolean/string/integer multivalue via an array todata-test-attribute
- The result of the boolean value should be1
add_attributes
function on an element within a Drupal twig templateClosing issues
emulsify-ds/emulsify-twig-extensions#4