Class: PageTemplate

Inherits:
DynamicView show all
Includes:
Templates
Defined in:
app/models/page_template.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Templates

default_body

Methods inherited from DynamicView

base_path, default_body, #display_name, #file_name, find_by_file_name, inherited, new_with_defaults, #remove_file_from_disk, #set_publish_on_save, write_all_to_disk!, #write_file_to_disk

Class Method Details

.display_name(file_name) ⇒ Object



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

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

.file_pathObject



14
15
16
# File 'app/models/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



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

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/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/page_template.rb', line 6

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