- π¨π¦Canada leducdubleuet Chicoutimi QC
This is exactly what I was looking for so the module works like it was in Drupal 7. The template should not introduce any whitespace other than the one(s) specified in the parameters.
So this patch applies cleanly and works really well, thank you very much to JeroenT!
Would it be possible to commit this patch into the next release please?
Thanks for this great module!
- π¨π¦Canada leducdubleuet Chicoutimi QC
This patch is still needed for the new 2.0.0-alpha2 release.
Here is a new simpler version of the patch based on 2.0.0-alpha2.
It would be great if this could be included in a new release please.
- π¦πΊAustralia sime Melbourne
This works great for me. For the googlers - be warned that twig debug being switched on makes it look like its not working.
- First commit to issue fork.
- Merge request !4Issue #3293086 by jeroent, mortona2k, leducdubleuet: Apply spaceless to templates to remove whitespaces β (Merged) created by mparker17
- π¨π¦Canada mparker17 UTC-4
Apologies; I didn't get a notification for this issue, so I didn't realize this ticket existed or that there was a patch ready.
I've created an issue fork, so that I can see if there are any test failures related to the changes in this ticket. I don't see any tests in the patch - but I'm not sure how one could write tests for this particular change - so I want to do some manual testing before I merge this.
- Status changed to Needs work
about 1 year ago 2:09am 26 March 2024 - π¨π¦Canada mparker17 UTC-4
Hmm... I'm seeing test failures, so I think we need to update the tests to account for the new functionality.
- πΊπΈUnited States mortona2k Seattle
Is this part of the project description correct?
Note that this module overrides the default Fields row style to output no extra whitespace for each row set other than the whitespace that already exist in field contents.
- π¨π¦Canada mparker17 UTC-4
@mortona2k, good point!
I just did some digging, and that paragraph was added to the project description for the original D6 version of the module ~13 years ago... apparently that functionality regressed sometime between the D6 version and when I became a (volunteer) maintainer of the project in ~2021 (and I must have missed it when I was adding automated tests in β¨ Add automated tests Fixed ).
I daresay the tests should be easy enough to fix: would you be willing to try your hand at fixing them?
- πΊπΈUnited States mortona2k Seattle
After staring at this for a bit, I think that there are various use cases for using this module, and there may be a better way to implement what you want. I see the value in a one size fits all or customizeable interface, but currently there are many edge cases that get in the way of using this.
That said, I'm contributing some fixes because it does work and I'm just being picky about html structure.
Some things to note:
The original proposal to use spaceless is now deprecated.
{{- -}} and {{~ ~}} are the replacement, and could potentially work. I think the template would all have to be on one line, and the comments twig debug comments may still be an issue. (I haven't fully explored {{~ ~}}).
This post has tricks on hiding whitespace, with some crafty HTML hacks.. https://css-tricks.com/fighting-the-space-between-inline-block-elements/
I have landed on CSS flex w/ flex wrap as the best way to implement this.
If I were doing this myself, I would make a custom view display or template.
Twig has a {{ loop.last }} variable that can be used within a for loop.
You can print a comma separator with:
<div{{ row.attributes.addClass(row_classes) }}> {{- row.content -}}{{ loop.last ?: ', ' }} </div>
See my comments in the MR for implementation concerns.
- πΊπΈUnited States mortona2k Seattle
mortona2k β changed the visibility of the branch 2.x to hidden.
- πΊπΈUnited States mortona2k Seattle
mortona2k β changed the visibility of the branch 3293086-remove-whitespace to hidden.
- π¨π¦Canada mparker17 UTC-4
Let's try applying things to 3.0.x first, then backporting to 2.x (the two branches are nearly identical except for the stated Drupal core version dependencies)
- π¨π¦Canada mparker17 UTC-4
Reviewing the issue, and chatting with @mortona2k in Slack yesterday and today, I was able to get the test working, and I think it better handles the Views data export β / Views Field View β use-case (i.e.: CSS isn't used in those cases) requested by @jeroent, so I'm going to re-instate the original merge request !4 and merge that one instead of !7.
That being said, I think @mortona2k's contributions in merge request !7 would make an excellent optional feature (so I've filed β¨ Find a way to make views_delimited_list work when twig debugging is turned on Active ); and he provided some extremely valuable contributions (i.e.: they taught me a bunch of things, uncovered some issues with the module, and did some research and work that will be useful in the future), so I am going to credit them in this issue.
Regarding the spaceless filter being deprecated, I'm going to file an issue after merging this one to fix that: I already have a solution.
Regarding Twig's loop.last feature, I think that will simplify things, but I don't want to change the scope of this issue, so I've created β¨ Simplify conjunctive case in Twig by using loop.last Active .
Also, my manual testing uncovered some setup nuances that were undocumented, so I plan to address them in β¨ Improve setup documentation Active .
- π¨π¦Canada mparker17 UTC-4
mparker17 β changed the visibility of the branch 3293086-remove-whitespace to active.
- π¨π¦Canada mparker17 UTC-4
mparker17 β changed the visibility of the branch 3293086-whitespace to hidden.
-
mparker17 β
committed aec4c291 on 3.0.x
Issue #3293086 by jeroent, mortona2k, leducdubleuet: Apply spaceless to...
-
mparker17 β
committed aec4c291 on 3.0.x
-
mparker17 β
committed c40b2e0c on 2.x
Issue #3293086 by jeroent, mortona2k, leducdubleuet: Apply spaceless to...
-
mparker17 β
committed c40b2e0c on 2.x
- π¨π¦Canada mparker17 UTC-4
Merged to 3.0.x and 2.x.
Follow-up to replace the (deprecated) spaceless filter with whitespace control is π Replace Twig spaceless filter with whitespace control Active .
I'll make a new 3.0.x and 2.x release soon!
Automatically closed - issue fixed for 2 weeks with no activity.