Module: Angelo::Tilt::ERB::ClassMethods
- Defined in:
- lib/angelo/tilt/erb.rb
Constant Summary collapse
- DEFAULT_LAYOUT =
'layout.html.erb'
Instance Method Summary collapse
- #default_layout ⇒ Object
- #layout_templates ⇒ Object
- #templates ⇒ Object
- #templatify(*glob) ⇒ Object
- #view_glob(*glob) ⇒ Object
Instance Method Details
#default_layout ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/angelo/tilt/erb.rb', line 43 def default_layout if @default_layout.nil? l = view_glob(DEFAULT_LAYOUT) @default_layout = ::Tilt::ERBTemplate.new l if File.exist? l end @default_layout end |
#layout_templates ⇒ Object
38 39 40 41 |
# File 'lib/angelo/tilt/erb.rb', line 38 def layout_templates @layout_templates ||= templatify 'layouts', '*.erb' @layout_templates end |
#templates ⇒ Object
33 34 35 36 |
# File 'lib/angelo/tilt/erb.rb', line 33 def templates @templates ||= templatify('**', '*.erb'){|v| v =~ /^layouts\//} @templates end |
#templatify(*glob) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/angelo/tilt/erb.rb', line 22 def templatify *glob Dir[view_glob *glob].reduce({}) do |h,v| sym = v.gsub view_dir + '/', '' return h if (block_given? && yield(v)) sym.gsub! '/', '_' sym.gsub! /\.\w+?\.erb$/, '' h[sym.to_sym] = ::Tilt::ERBTemplate.new v h end end |
#view_glob(*glob) ⇒ Object
18 19 20 |
# File 'lib/angelo/tilt/erb.rb', line 18 def view_glob *glob File.join view_dir, *glob end |