Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
4.0.4 changes to doWrap causing problems
Essentially: in version 4.0.4 the doWrap() function in taghandlers.php was changed, and the change is causing a problem for my plugin (tru_tags). The problem can be seen simply by calling doWrap() with a blank $wraptag and a $break of ‘, ‘. In 4.0.3, doWrap() would end up calling join($break.n,$list);. In 4.0.4, doWrap() now calls join(n.$break, $list);. The only difference is that the newline moved from after the $break to before it.
My plugin is configured by default to call doWrap with a $wraptag of ‘’ and a $break of ‘, ‘ so when the newline is prepended to the $break it appears on the page with a space before and after the comma.
It seems strange that the newline is applied at all, but I suppose I can understand that if no $wraptag was passed in, then you might assume that the caller might like the convenience. But I don’t understand why the newline moved – the ‘before’ version seems a little backwards. It’s also inconsistent with all the other join() calls in that method, so I’m assuming that it’s a bug and reporting it here.
For my plugin, it looks like the least-painful way for me to work around the problem is to always pass a $wraptag of ‘span’ (by default). I can’t think of any other solution that isn’t likely to mess with the page layout of my users. But do any of you have any suggestions? I can give more details on the problem if it isn’t clear.
Offline
#2 2006-11-13 23:25:10
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: 4.0.4 changes to doWrap causing problems
The problem is in the assumption: break is meant for tags, not text.
The solution: just copy doWrap, rename it (say tru_doWrap), customize it as you want, and stick it in your plugin. I have done this myself whenever a built-in function didn’t do exactly what I needed for my plugin.
Offline
Re: 4.0.4 changes to doWrap causing problems
To make sure I understand: you’re saying that the ‘break’ attribute is expecting to be passed a tag name (like ‘li’) and not text characters (like ‘,’), right?
I suppose I can understand that, and I’ll make my own function as you suggested. But I still don’t really get why the newline was moved – why is this one case different than all the others?
Thanks for the quick response!
Offline
#4 2006-11-14 04:52:58
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: 4.0.4 changes to doWrap causing problems
…you’re saying that the ‘break’ attribute is expecting to be passed a tag name (like ‘li’) and not text characters (like ‘,’), right?
Yes, though of course it’s smart enough that if it doesn’t recognize it as a tag, it won’t format it as such (and you won’t be able to use a breakclass).
I just committed (r2081) a slight variation that should likely help: if it doesn’t recognize it as a tag, no newline is added at all.
From what you describe, as well as taking a quick peek at your plugin, it sounds like what you really want to do is offer a separator attribute, in addition to break. :)
Offline
Re: 4.0.4 changes to doWrap causing problems
I realized I never replied to this – thank you!
Offline