Sha256: f77cef4105d6cac673592ad2a6d001aac46fd1935981fedce18987a06b90ef12
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
module Templates class TemplatesController < ApplicationController unloadable def index render :json => collect_templates end protected def collect_templates app_templates = {} Dir.new("#{RAILS_ROOT}/app/controllers").entries.each do |controller_file_name| if controller_file_name =~ /_controller/ controller_name = controller_file_name.camelize.gsub('.rb', '') if controller_name != 'ApplicationController' controller = controller_name.constantize templates_hash = {} unless controller.templates_options.nil? if controller.templates_options[:layout] templates_hash[:layout] = render_to_string(:file => "layouts/#{controller.controller_name}", :layout => false) end if controller.templates_options[:partials].count > 0 templates_hash[:partials] = {} controller.templates_options[:partials].each do |partial| templates_hash[:partials][partial] = render_to_string(:file => "#{controller.controller_name}/_#{partial}", :layout => false) end end end if not controller.templates_list.nil? and controller.templates_list.count > 0 templates_hash[:templates] = {} controller.templates_list.each do |template| templates_hash[:templates][template] = render_to_string(:file => "#{controller.controller_name}/#{template}", :layout => false) end end app_templates[controller.controller_name] = templates_hash unless templates_hash.empty? end end end app_templates end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
templates-0.1.0 | app/controllers/templates/templates_controller.rb |