Module: Ext::ErubyView::Base
- Defined in:
- lib/ext/eruby_view.rb
Instance Method Summary collapse
-
#eruby_template(view) ⇒ Object
Returns the path or nil from a view name.
-
#eruby_view(m, *a, &b) ⇒ Object
Compiles an eruby template from current instance variables, helpers and the template.
-
#eruby_view?(view) ⇒ Boolean
Checks if the view exists as an eruby template.
-
#has_view?(view) ⇒ Boolean
Generic wrapper.
-
#view(m, *a, &b) ⇒ Object
Generic wrapper.
Instance Method Details
#eruby_template(view) ⇒ Object
Returns the path or nil from a view name. Template extensions are .erb.
57 58 59 60 |
# File 'lib/ext/eruby_view.rb', line 57 def eruby_template(view) file = File.join(template_root, "#{view}.erb") File.exists?(file) ? file : nil end |
#eruby_view(m, *a, &b) ⇒ Object
Compiles an eruby template from current instance variables, helpers and the template
TODO : Support splat and block TODO : Implement parse caching here NOTE : Override @headers if necessary here
76 77 78 79 |
# File 'lib/ext/eruby_view.rb', line 76 def eruby_view(m, *a, &b) e = ::ERB.new(File.read(eruby_template(m))) e.result(ivs_send(app::V.new).bind(m,*a,&b)) # instance variables are wrapped in V end |
#eruby_view?(view) ⇒ Boolean
Checks if the view exists as an eruby template
50 51 52 53 54 |
# File 'lib/ext/eruby_view.rb', line 50 def eruby_view?(view) if /text\/html|\*\/\*/ =~ (env.HTTP_ACCEPT || '*/*') return true if eruby_template(view) end end |
#has_view?(view) ⇒ Boolean
Generic wrapper. Forwards to #eruby_view? or ask parent.
44 45 46 47 |
# File 'lib/ext/eruby_view.rb', line 44 def has_view?(view) return true if eruby_view?(view) super end |
#view(m, *a, &b) ⇒ Object
Generic wrapper. Forwards to #eruby_view or ask parent.
63 64 65 66 67 68 |
# File 'lib/ext/eruby_view.rb', line 63 def view(m, *a, &b) if eruby_view?(m) return eruby_view(m, *a, &b) end super end |