[ic] Usertag Alias function and hyphens

Josh Lavin josh at perusion.com
Tue Dec 24 21:29:01 UTC 2013


Quoting Jon Jensen (jon at endpoint.com):
> 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. :)

That looks good to me. Fixed and pushed!

-- 
Josh Lavin
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
... ask me about job opportunities ...



More information about the interchange-users mailing list