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.11.0 app/models/effective/templates/template.rb
effective_regions-1.10.3 app/models/effective/templates/template.rb
effective_regions-1.10.2 app/models/effective/templates/template.rb
effective_regions-1.10.1 app/models/effective/templates/template.rb
effective_regions-1.10.0 app/models/effective/templates/template.rb
effective_regions-1.9.0 app/models/effective/templates/template.rb
effective_regions-1.8.6 app/models/effective/templates/template.rb
effective_regions-1.8.5 app/models/effective/templates/template.rb
effective_regions-1.8.4 app/models/effective/templates/template.rb
effective_regions-1.7.6 app/models/effective/templates/template.rb
effective_regions-1.8.3 app/models/effective/templates/template.rb
effective_regions-1.8.2 app/models/effective/templates/template.rb
effective_regions-1.8.1 app/models/effective/templates/template.rb
effective_regions-1.8.0 app/models/effective/templates/template.rb
effective_regions-1.7.5 app/models/effective/templates/template.rb
effective_regions-1.7.4 app/models/effective/templates/template.rb
effective_regions-1.7.3 app/models/effective/templates/template.rb
effective_regions-1.7.2 app/models/effective/templates/template.rb
effective_regions-1.7.1 app/models/effective/templates/template.rb
effective_regions-1.7.0 app/models/effective/templates/template.rb