Sha256: 9bb42d9665d388de3cccfca777ce48bc9d23ac4bab3955a9c0934f560548d41f

Contents?: true

Size: 1.08 KB

Versions: 35

Compression:

Stored size: 1.08 KB

Contents

module Effective
  module Templates
    class Template

      # This is used by the effective_regions_helper effective_regions_include_tags
      # And ends up in the javascript CKEDITOR.config['effective_regions'] top level namespace
      # Passing the controller is hacky but it works
      def self.definitions(controller)
        EffectiveRegions.templates.map do |template|
          {
            :title => template.title,
            :description => template.description,
            :image => template.image || "#{template.class_name}.png",
            :html => controller.render_to_string(:partial => template.to_partial_path, :object => template, :locals => {:template => template})
          }
        end
      end

      def title
        class_name.to_s.humanize
      end

      def description
        "Insert #{title}"
      end

      def image
        "#{class_name}.png"
      end

      def to_partial_path
        "effective/templates/#{class_name}"
      end

      def class_name
        @class_name ||= self.class.name.demodulize.underscore.to_sym
      end

    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
effective_regions-1.6.14 app/models/effective/templates/template.rb
effective_regions-1.6.12 app/models/effective/templates/template.rb
effective_regions-1.6.11 app/models/effective/templates/template.rb
effective_regions-1.6.10 app/models/effective/templates/template.rb
effective_regions-1.6.9 app/models/effective/templates/template.rb
effective_regions-1.6.8 app/models/effective/templates/template.rb
effective_regions-1.6.7 app/models/effective/templates/template.rb
effective_regions-1.6.6 app/models/effective/templates/template.rb
effective_regions-1.6.5 app/models/effective/templates/template.rb
effective_regions-1.6.4 app/models/effective/templates/template.rb
effective_regions-1.6.3 app/models/effective/templates/template.rb
effective_regions-1.6.2 app/models/effective/templates/template.rb
effective_regions-1.6.1 app/models/effective/templates/template.rb
effective_regions-1.6.0 app/models/effective/templates/template.rb
effective_regions-1.5.0 app/models/effective/templates/template.rb