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 <>
  • Loading branch information...
davec authored and Bruce Williams committed Apr 7, 2009
1 parent 9faca89 commit a694e0afa4c57347a48ad09d6e845ba2c589e8f0
Showing with 9 additions and 2 deletions.
  1. +9 −2 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
alias :l :latex_escape

0 comments on commit a694e0a

Please sign in to comment.