[TxMt] HTML Navbar, proof of concept

Brett Terpstra brett at circlesixdesign.com
Thu Oct 26 13:53:30 UTC 2006


Andreas' question got me thinking about the regexp in the Heading  
[1,2] snippets and in my HTML Navbar snippet.  I came up with these  
two replacements:

/(\w)+|( )+|([[:punct:]])+/(?1:\L$0)(?2:_)(?3:)/g

pulls out punctuation, lowercases everything and replaces spaces with  
underscores.  Basically the same as before but with punctuation  
stripped and multiple spaces treated as a single underscore.  "It's  
Getting Dark" becomes its_getting_dark.

/(\w)+|([[[:punct:]]|\s]+(\w))|([[[:punct:]]|\s])+/(?1:\L$0)(?2:\u$3) 
(?4:)/g

Camelcase regexp, strips whitespaces and punctuation and capitalizes  
the character after a space.  Seems to work well, but I'm admittedly  
poor at regular expressions.
"It's getting darker and darker" becomes itsGettingDarkerAndDarker.

Brett


On Oct 26, 2006, at 5:02 AM, Brett Terpstra wrote:

> It creates a lowercase class name without spaces based on the text  
> of the link (I borrowed it from the "Heading" snippets), the idea  
> being that when I create a navbar I add a class--say if the link is  
> Home, the class would be "home"--and then add a body id to each  
> linked page that allows me to easily highlight the current menu  
> item without using PHP.  It's the "Andy Budd" method.  Like I said,  
> it's just proof of concept, I actually use the concept more often  
> to just create unordered lists without all the extra code...
>
> Brett
>
>
> On Oct 26, 2006, at 4:21 AM, Andreas Wahlin wrote:
>
>> Ehm, what's with the big regexp in the class attribute? What does  
>> it do :)
>>
>> Andreas
>>
>>
>> _____________________________________________________________________ 
>> _
>> For new threads USE THIS: textmate at lists.macromates.com
>> (threading gets destroyed and the universe will collapse if you  
>> don't)
>> http://lists.macromates.com/mailman/listinfo/textmate
>
> Brett Terpstra : Art Director
> Circle Six Design, Inc.
> 111 Riverfront Dr, Suite 204
> ..................................................
> p: 507.459.4398
>     877.858.4332
> f: 1.866.540.3063
> e: brett at circlesixdesign.com
> http://www.circlesixdesign.com
> ..................................................
>
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate




More information about the textmate mailing list