Class: Cms::PageTemplate

Inherits:
DynamicView
  • Object
show all
Defined in:
app/models/cms/page_template.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DynamicView

base_path, default_body, #display_name, #file_name, find_by_file_name, new_with_defaults, #set_defaults, #set_path, #set_publish_on_save, title, with_file_name

Methods included from DefaultAccessible

#non_permitted_params, #permitted_params

Class Method Details

.display_name(file_name) ⇒ Object



18
19
20
21
22
# File 'app/models/cms/page_template.rb', line 18

def self.display_name(file_name)
  name, format, handler = file_name.split('.')
  content_type = handler ? "#{format}/#{handler}" : "#{format}"
  "#{name.titleize} (#{content_type})"
end

.file_pathObject



14
15
16
# File 'app/models/cms/page_template.rb', line 14

def self.file_path
  File.join(base_path, relative_path)
end

.optionsObject

This is a combination of file system page templates and database page templates



26
27
28
29
30
# File 'app/models/cms/page_template.rb', line 26

def self.options
  file_system_templates = ActionController::Base.view_paths.map { |p| Dir["#{p}/#{relative_path}/*"] }.flatten.map { |f| File.basename(f) }
  page_templates = file_system_templates + all.map { |t| t.file_name }
  page_templates.map { |f| [display_name(f), f] }.sort.uniq
end

.relative_pathObject



10
11
12
# File 'app/models/cms/page_template.rb', line 10

def self.relative_path
  File.join("layouts", "templates")
end

Instance Method Details

#file_pathObject



6
7
8
# File 'app/models/cms/page_template.rb', line 6

def file_path
  File.join(self.class.file_path, file_name)
end

#hintObject

Generates hint for editing



41
42
43
# File 'app/models/cms/page_template.rb', line 41

def hint
  "No spaces allowed. Must start with lowercase letter."
end

#partial?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/cms/page_template.rb', line 32

def partial?
  false
end

#placeholderObject



36
37
38
# File 'app/models/cms/page_template.rb', line 36

def placeholder
  "subpage"
end