Skip to content

Commit

Permalink
Allow latex_escape to work in a Rails 2.2+ environment
Browse files Browse the repository at this point in the history
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
davec authored and Bruce Williams committed Apr 14, 2009
1 parent 9faca89 commit a694e0a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/rtex/framework/rails.rb
Expand Up @@ -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
Expand Down

0 comments on commit a694e0a

Please sign in to comment.