| Class | Atchoum::Website |
| In: |
lib/atchoum/website.rb
|
| Parent: | Markaby::Builder |
| pages | [R] | |
| reloader | [R] |
# File lib/atchoum/website.rb, line 12
12: def initialize
13: super
14: @pages = public_methods.collect do |m|
15: /^(\w+)_page$/ =~ m ? $1 : nil
16: end.compact
17: end
Default layout for every renderd page. Redefine this to setup a custom layout.
# File lib/atchoum/website.rb, line 21
21: def layout
22: html do
23: body do
24: self << yield
25: end
26: end
27: end
Render the content of a page as a string containing the magic HTML.
# File lib/atchoum/website.rb, line 31
31: def render(page)
32: @rendered_page = page.to_sym
33: s = capture { send("#{page}_page") }
34: s = capture { send(:layout) { s } } if respond_to? :layout
35: @rendered_page = nil
36: s
37: end
Render all pages to seperate html files in correponding folders. For exemple, index_page will be parsed to +/index.htm+ and contact_page to +/contact/index.htm+.
# File lib/atchoum/website.rb, line 42
42: def to_files
43: pages.each do |page|
44: if page.to_s == 'index'
45: path = '.'
46: else
47: path = page
48: Dir::mkdir path if !File.exist? path
49: end
50: File.open("#{path}/index.htm", 'w') do |f|
51: f << render(page)
52: end
53: end
54: end