Class: Effective::Templates::Template

Inherits:
Object
  • Object
show all
Defined in:
app/models/effective/templates/template.rb

Direct Known Subclasses

ImageAndTitle, ThreeColumn, TwoColumn

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.definitions(controller) ⇒ Object

This is used by the effective_regions_helper effective_regions_include_tags And ends up in the javascript CKEDITOR.config top level namespace Passing the controller is hacky but it works



8
9
10
11
12
13
14
15
16
17
# File 'app/models/effective/templates/template.rb', line 8

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

Instance Method Details

#class_nameObject



35
36
37
# File 'app/models/effective/templates/template.rb', line 35

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

#descriptionObject



23
24
25
# File 'app/models/effective/templates/template.rb', line 23

def description
  "Insert #{title}"
end

#imageObject



27
28
29
# File 'app/models/effective/templates/template.rb', line 27

def image
  "#{class_name}.png"
end

#titleObject



19
20
21
# File 'app/models/effective/templates/template.rb', line 19

def title
  class_name.to_s.humanize
end

#to_partial_pathObject



31
32
33
# File 'app/models/effective/templates/template.rb', line 31

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