Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
The BB Code from Train
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
Gemfile.lock
README.rdoc
Rakefile
init.rb
trainbbcode.gemspec

README.rdoc

Train BBCode

Homepage

Rails Gem for BBCode

Install

Add:

gem "trainbbcode"

to your Gemfile and then install the gem using:

bundle install

Usage

The easiest way to use tbbc is with the string method provided, for example

>> "[b]Bold[/b]".tbbc
=> "<strong>Bold</strong>"

Configuration

On the fly

If you want to quickly change something, e.g. disable a tag for a specific .tbbc call then you can configure it in the call:

>> "[b]Bold[/b] [i]Italic[/i]".tbbc(:strong_enabled => false)
=> "[b]Bold[/b] <i>Italic</i>"

Whilst this method works its not the cleanest way of doing it. Its fine for simple things like disabling a single tag (e.g. tables in signatures) but when defining custom tags or the coderay css its better to use the other config method

Globaly

This is done using config/initializers/tbbc.rb, this file needs to look like this:

Trainbbcode.configure do |c|
    c.strong_enabled = false

end

That would produce the same output as the on the fly config but would work when ever you used .tbbc in the project.

Something went wrong with that request. Please try again.