lib/masterview/extras/app/controllers/masterview_controller.rb in masterview-0.2.3 vs lib/masterview/extras/app/controllers/masterview_controller.rb in masterview-0.2.4

- old
+ new

@@ -42,12 +42,12 @@ # We'll have to leave this as an exercise for the user and give # them tips on how to make it happen. # [DJL 17-Jun-2006] #++ # +require 'masterview/extras/sample_templates' - class MasterviewController < ApplicationController before_filter :check_authorization, :except => [ :access_not_allowed ] ENABLE_ADMIN_LAYOUT = false #:nodoc: #UNDER CONSTRUCTION - fine idea, but doesn't work yet [DJL 03-Jun-2006] @@ -139,9 +139,26 @@ raise "RHTML file not specified" unless @rhtml_file f = MasterView::IOMgr.erb.path(@rhtml_file) raise "RHTML file ("+@rhtml_file+") not found. Maybe automatic parsing is disabled. You may invoke parsing manually by using rake mv:parse" unless f.exist? @rhtml_content = f.read smart_render 'masterview/admin/view_rhtml' + end + + # interact, test template src, view results + def interact + @results = [] + @src = params[:src] + if @src + sh_mio = MasterView::StringHashMIOTree.new({}, '.rhtml') + MasterView::Parser.parse( @src, { :output_mio_tree => sh_mio, :omit_comment => true } ) + @results = sh_mio.string_hash.sort.collect do |file,rhtml| + os = OpenStruct.new + os.file = file + os.rhtml = rhtml + os + end + end + smart_render 'masterview/admin/interact' end def access_not_allowed #:nodoc: render :text => '<p>We\'re sorry, but the page you have requested is only available to authorized users.</p>', :status => 500