[ic] Usertag Alias function and hyphens

Jon Jensen jon at endpoint.com
Fri Dec 20 09:01:55 UTC 2013


On Thu, 19 Dec 2013, Josh Lavin wrote:

> I found that when trying to create an Alias like this:
>
> UserTag edisplay Alias error auto=1 class="list-unstyled alert alert-danger"
>
> ... that the end result would turn the hyphens into underscores, thus 
> breaking the class I intended to use.
>
> The problem is the transliteration operator below, which was originally 
> added to allow aliases like [shipping-description] to work. However, I 
> believe we should apply the patch below so the tr/// only happens on the 
> first word, which would be the actual tag alias value, and skip the 
> tr/// on the remaining parts.

That behavior change makes sense to me.

I would quibble with the implementation that feels cumbersome using split 
and join. If we were using Perl 5.14+ we could use the nice new "r" 
modifier to tr pretty simply like this:

s{^(\S+)}{ $1 =~ tr/-/_/r }e;

But to be compatible back to Perl 5.8, we have to manually copy from the 
read-only $1 capture variable:

s{^(\S+)}{ $_ = $1; tr/-/_/; $_ }e;

That still seems simpler to read for me, but maybe it's just in the eye of 
the reader. :)

Anyway, +1 on fixing the bug.

Jon

-- 
Jon Jensen
End Point Corporation
http://www.endpoint.com/



More information about the interchange-users mailing list