Skip to content
Browse files

Allow latex_escape to work in a Rails 2.2+ environment

Since Rails 2.2 aliases l() as localize(), this leads to conflicts with
RTeX's aliasing of l() as latex_escape(). To work around the conflict,
this patch forces latex_escape to pass control on to localize if rtex is
not doing the rendering.

Signed-off-by: Bruce Williams <bruce@codefluency.com>
  • Loading branch information...
1 parent 9faca89 commit a694e0afa4c57347a48ad09d6e845ba2c589e8f0 @davec committed with bruce
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/rtex/framework/rails.rb
View
11 lib/rtex/framework/rails.rb
@@ -55,8 +55,15 @@ def render_with_rtex(options=nil, *args, &block)
module HelperMethods
# Similar to h()
- def latex_escape(s)
- RTeX::Document.escape(s)
+ def latex_escape(*args)
+ # Since Rails' I18n implementation aliases l() to localize(), LaTeX
+ # escaping should only be done if RTeX is doing the rendering.
+ # Otherwise, control should be be passed to localize().
+ if Thread.current[:_rendering_rtex]
+ RTeX::Document.escape(*args)
+ else
+ localize(*args)
+ end
end
alias :l :latex_escape
end

0 comments on commit a694e0a

Please sign in to comment.
Something went wrong with that request. Please try again.