]> git.wincent.com - wikitext.git/commitdiff
Fix breakage caused by recent Rails API changes
authorWincent Colaiuta <win@wincent.com>
Sun, 4 Jan 2009 05:24:26 +0000 (06:24 +0100)
committerWincent Colaiuta <win@wincent.com>
Sun, 4 Jan 2009 05:29:58 +0000 (06:29 +0100)
The API has now changed so many times in unfathomable (uncommented) ways
that I'm no longer going to support older versions of Rails. The runtime
checks for all the myriad variations are just getting too complicated
and I can't justify maintaining them, especially seeing as I have no
intention of keeping old Rails installations on hand for the purposes of
testing.

The present version is tested and works with Rails 2.2.2. I actually had
a couple of intermediate, but uncommitted, unreleased changes, that I
needed to keep other versions of Rails working (2.1.0RC1, for example).
In the end those changes were short-lived because the API was changed
repeatedly afterwards.

In the latest rounds of changes, the "compilable?" method is no longer
checked, "call" is now invoked anyway, and Rails then proceeds to
evaluate the returned string as Ruby code in some unknown context where
"template" is a local variable! The "render" method is no longer called.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
lib/wikitext/rails.rb

index a04275ae124c8c8ec2d6a0cf110cf6375389ca8a..4576a8ffaff7442b467cb3f5d0bea1ed07f52be9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2008 Wincent Colaiuta
+# Copyright 2008-2009 Wincent Colaiuta
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
@@ -16,18 +16,10 @@ require 'wikitext/string'
 
 module Wikitext
   class TemplateHandler
-    def initialize view; end
 
-    def render text, locals = {}
-      text.w
+    # tested with Rails 2.2.2: the API has now changed so many times that I'm no longer going to support older versions of Rails
+    def self.call template
+      'template.source.w'
     end
   end
 end
-
-if ActionView::Template.respond_to? :register_template_handler  # Rails 2.1.0_RC1 and above
-  ActionView::Template.register_template_handler :wikitext, Wikitext::TemplateHandler
-elsif ActionView::Base.respond_to? :register_template_handler   # Rails 2.0.2
-  ActionView::Base.register_template_handler :wikitext, Wikitext::TemplateHandler
-else
-  raise "Incompatible Rails API version (can't find register_template_handler method)"
-end