Class: PageTemplate
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_path ⇒ Object
14
15
16
|
# File 'app/models/page_template.rb', line 14
def self.file_path
File.join(base_path, relative_path)
end
|
.options ⇒ Object
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_path ⇒ Object
10
11
12
|
# File 'app/models/page_template.rb', line 10
def self.relative_path
File.join("layouts", "templates")
end
|
Instance Method Details
#file_path ⇒ Object
6
7
8
|
# File 'app/models/page_template.rb', line 6
def file_path
File.join(self.class.file_path, file_name)
end
|