Skip to content

Commit

Permalink
Add Rails 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath committed Oct 25, 2010
1 parent 2326cc3 commit 395d182
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
15 changes: 12 additions & 3 deletions lib/trainbbcode.rb
Expand Up @@ -8,8 +8,10 @@
require 'coderay'

#Helper Method
require 'trainbbcode/application_helper.rb'
ActionView::Base.send :include, TBBCHelper
if defined? Rails
require 'trainbbcode/application_helper.rb'
ActionView::Base.send :include, TBBCHelper
end

class TBBC
# Creates a new TBBC class with everything set to default
Expand Down Expand Up @@ -47,5 +49,12 @@ def coderay(input)
end
input
end


def needs_html_safe?
if defined? Rails
return Rails.version =~ /^3\./
else
return false
end
end
end
9 changes: 7 additions & 2 deletions lib/trainbbcode/css.rb
@@ -1,5 +1,6 @@
class TBBC


# Returns the css required for coderay
def css(config = nil)
conf config
output=" <style type=\"text/css\">
Expand Down Expand Up @@ -37,6 +38,10 @@ def css(config = nil)
.CodeRay .ta { #{@config[:syntax_highlighting_html]} } /* html tag */
.CodeRay .pc { #{@config[:syntax_highlighting_boolean]} } /* boolean */
</style>"
return output
if needs_html_safe? then
return output.html_safe
else
return output
end
end
end
6 changes: 5 additions & 1 deletion lib/trainbbcode/parse.rb
Expand Up @@ -32,6 +32,10 @@ def parse(input)
end
end
input=correctbrs input
return input
if needs_html_safe? then
return input.html_safe
else
return input
end
end
end

0 comments on commit 395d182

Please sign in to comment.