diff --git a/lib/redcloth.rb b/lib/redcloth.rb index 376d022..9f92cf9 100644 --- a/lib/redcloth.rb +++ b/lib/redcloth.rb @@ -28,23 +28,16 @@ require 'redcloth/formatters/latex' module RedCloth - + # A convenience method for creating a new TextileDoc. See # RedCloth::TextileDoc. def self.new( *args, &block ) RedCloth::TextileDoc.new( *args, &block ) end - + # Include extension modules (if any) in TextileDoc. def self.include(*args) RedCloth::TextileDoc.send(:include, *args) end - -end -begin - require 'erb' - require 'redcloth/erb_extension' - include ERB::Util -rescue LoadError end diff --git a/lib/redcloth/erb_alias_extension.rb b/lib/redcloth/erb_alias_extension.rb new file mode 100644 index 0000000..8c8006f --- /dev/null +++ b/lib/redcloth/erb_alias_extension.rb @@ -0,0 +1,15 @@ + +require 'erb' +require 'redcloth/erb_extension' + +class ERB + module Util + alias t textilize + module_function :t + end +end + +begin + include ERB::Util +rescue LoadError +end diff --git a/lib/redcloth/erb_extension.rb b/lib/redcloth/erb_extension.rb index a30486e..edc17ab 100644 --- a/lib/redcloth/erb_extension.rb +++ b/lib/redcloth/erb_extension.rb @@ -19,8 +19,6 @@ def textilize( s ) end end - alias t textilize - module_function :t module_function :textilize end diff --git a/spec/erb_spec.rb b/spec/erb_spec.rb index 71c11b6..97c222b 100644 --- a/spec/erb_spec.rb +++ b/spec/erb_spec.rb @@ -1,4 +1,5 @@ require File.dirname(__FILE__) + '/spec_helper' +require 'redcloth/erb_alias_extension' describe "ERB helper" do it "should add a textile tag to ERB" do