Skip to content
Arcath edited this page Jul 13, 2012 · 1 revision

When creating a tag instead of a matcher you can pass an instance of Markabb::Callback which lets you run custom code of the matched text.

A simple example would be an [up] tag which upcases text, using sting tag matcher you would do:

Markabb::Tag.new('up',Markabb::Callback.new(Proc.new { |s|
    s.upcase
}))

When Markabb::Parser matches "[up]foo[/up]" it passes the whole thing the Markabb::Tag instance which in turn runs .call(['foo'])on the Markabb::Callback object which passes the array to the Proc you wrote.

The Proc can contain any code you want and be passed any number of options.

If you pass any options into an ActiveRecord query make sure you sanitise them first

Clone this wiki locally