Posts

Showing posts with the label tips

Template Tooltip Tip #1

A bit of background Template toolkit is a powerful and mature Perl  based templating engine. It is designed to be output format agnostic and used (or able to be used) with most of the Perl based Web application frameworks like Dancer , Catalyst and CGI::Application . TT Tip #1 - Simple html attribute macro In this tip, i'll combine using a TT macro with HTML plugin to create a simple macro to add active class to html element. code TT code: (put in top of template or shared TT file pulled in with PROCESS or INCLUDE) [% USE HTML %] [% MACRO active GET HTML.attributes( 'class' => 'active' ) %] Usage in a template: <ul id="navBar"> <li [% active IF page.name == 'home' %]>Home</li> <li [% active IF page.name == 'about' %]>about</li> <li [% active IF page.name == 'contact' %]>contact</li> </ul> In this case, when page.name matches then macro will drop in ...

vim makes me pasty when pasting

For a while its bugged me that when I paste into a vim session with all nice options turned on, it formats the crap out of it. At some point setting set noautoindent stopped fixing this problem. Thank goodness that I found a solution, it probably exists for years but with vim sometimes knowing the right verbage is the key to a finding how to do it. (its probably been there since version 5.0) Here is how it works for me: pre paste - :set paste paste in code/snippet/sql/guinea pig :set nopaste Man that makes my life so much easier...