15
September
2010

TrainBBCode goes Stable!

Tagged: TrainBBCode Rails Gems
Comments
Facebook_share Twitter_share Reddit_share
For Train (The CMS that preceded this blog) I wrote a BBCode plugin in to start off with it was called like this:


1t=TBBC.new
2t.config(OPTIONS)
3t.parse("String")




Which is ugly to say the least, and a PITA to configure. I still use this ancient version of the plugin on something I wrote for work and its in dire need of an upgrade.

The new version works allot better, the biggest improvement is a configurable call on strings, for example:


1"String".tbbc(OPTIONS)




OPTIONS in this case is optional, you can run .tbbc with all defaults, which will include the global config which you can set in config/tbbc.rb (in your rails config directory). This means that it is possible to have one global config that controls all the .tbbc calls, this is perfect for defining custom tags like the gist tag here. In my config/tbbc.rb I have:



which turns [gist�[/gist] into what you see above. This improvement has long been needed, I found myself defining the same custom tags every time I used .tbbc and my only solution was to move the .tbbc call into a rails helper method which was fine for that project but not what you the rails community will be looking for in a gem so I added tbbc.rb. A simple solution that greatly increases the usability of tbbc, things look so much neater when even with custom tags etc... <%= post.body.tbbc %> is all you need in a view.
blog comments powered by Disqus
Html5-badge-h-css3-graphics-semantics
CSS Based on Twitters Bootstrap

88x31
All Content is written by Adam Laycock (Arcath) unless otherwise stated.

A little bit About Me

I am an IT Technician working in Primary Schools, I spend my time outside work writing programs, normally they end up bieng bots and other web based dodads