Tips, Tricks and Extras

Possible Gotcha's

Handling non-autostringified methods

If you want to make a direct, non-@helpers call to a method that doesn't auto-stringify, and thus gets output directly to the buffer, such as a named_route, just call to_s on it.

form_for :resource_name, url => resource_name_path(@instance).to_s

Name clashes

You cannot name your local assigns or instance variables with names that are already defined by helpers e.g. 'tag' in Rails won't work. The solution is to tell Markaby to ignore the helpers, and to give preference to the assigns/variables. For example (in Rails, put this in your config/environment.rb):

Markaby::Builder.ignore_helpers :tag

Indent the code

By default, Markaby produces an html tag soup. If you want to print the html more clearly, you can but take care because it makes things much slowlier.

Markaby::Builder.set(:indent, 2)