[Catalyst] create search engine friendly uri from string

J. Shirley jshirley at gmail.com
Mon Dec 15 22:14:16 GMT 2008


On Mon, Dec 15, 2008 at 1:23 PM, Moritz Onken <onken at houseofdesign.de> wrote:
>
> Am 15.12.2008 um 21:53 schrieb Johannes Plunien:
>
>>> On 15.12.2008, at 21:22, Jim Spath wrote:
>>>
>>>> You might also want to add these two to the end:
>>>>
>>>> =~ s/--+/-/g;
>>>> =~ s/-$//g;
>>>>
>>>> Scott McWhirter wrote:
>>>>>
>>>>> $str =~ s{\W}{}g;
>>>>> $str = lc($str);
>>>>> $str =~ s{\s+}{-}g;
>>
>> My not very elegant, but working solution:
>>
>> my $str = "  Beta Launch Invites: Kwyno Brings The Web Into Your IM And
>> (Soon) SMS Inboxes  ";
>> $str =~ s/^\s+|\s+$//g;
>> $str =~ s/\W/ /g;
>> $str =~ s/\s{1,}/ /g;
>> $str =~ s/\s/-/g;
>> $str = lc($str);
>>
>> print "$str\n";
>
> You are so great. Thanks guys!
>
> What do you think? should I put those in a Template Plugin module and push
> it to the CPAN?
>
> Any name suggestions?
>
> cheers
>

I've been meaning to, for use with DBIx::Class::Tokenize ... but
better to have something like Text::Filter::URI and then a Template
Toolkit Filter that simply uses that underlying module.

Just my $0.02,

-J



More information about the Catalyst mailing list