# Radiant ERB (Embedded Ruby) filter # ================================== # # Provides ERB support for Radiant content. For more about Radiant see # "http://radiantcms.org/". # # # History # ------- # # 2006-07-14 (ADH): Created. # 2006-07-15 (ADH): Added 'description' field, currently commented out # until wider support in Filters is present. # 2006-07-25 (ADH): Extended models/behavior.rb to call an extended # filter interface including a hash of instance # variables. Implemented that interface here, using # the ActionView-derived magic first implemented in # the ERB Behavior code to define the hash variables # in the context of the ERB interpreter. # 2011-03-08 (ADH): Imported into Radiant 0.9.1 as an Extension. require_dependency 'application_controller' class ErbFilterExtension < Radiant::Extension version "2.0" description "Allows the use of ERB within pages, with support for Rails request and session details" url "http://pond.org.uk/" def activate ApplicationController.class_eval do around_filter :break_mvc_for_erb_filter_use_in_view_via_radiant_model def break_mvc_for_erb_filter_use_in_view_via_radiant_model methods = ["session", "request"] methods.each do |method| value = send(method) unless (ErbFilter.new.respond_to?(method)) ErbFilter.send(:define_method, method, proc { value }) end end yield methods.each do |method| if (ErbFilter.new.respond_to?(method)) ErbFilter.send( :remove_method, method ) end end end end ErbFilter Page.send :include, ErbTags end end