Module: WSOC::Helpers::Rendering
- Included in:
- WSOC::Helpers
- Defined in:
- lib/wsoc/helpers/rendering.rb
Instance Method Summary collapse
-
#json(obj) ⇒ String
Renders a JSON blob and sets the content-type accordingly.
-
#partial(page, options = {}) ⇒ String
Renders a partial template.
-
#show(page, options = {}) ⇒ String
Renders a page.
-
#yaml(obj) ⇒ String
Renders a YAML blob and sets the content-type accordingly.
Instance Method Details
#json(obj) ⇒ String
Renders a JSON blob and sets the content-type accordingly.
83 84 85 86 87 88 |
# File 'lib/wsoc/helpers/rendering.rb', line 83 def json(obj) content_type :json obj = obj.to_s unless obj.respond_to?(:to_json) return obj.to_json end |
#partial(page, options = {}) ⇒ String
Renders a partial template.
44 45 46 |
# File 'lib/wsoc/helpers/rendering.rb', line 44 def partial(page,={}) erb "_#{page}".to_sym, .merge(:layout => false) end |
#show(page, options = {}) ⇒ String
Renders a page.
65 66 67 |
# File 'lib/wsoc/helpers/rendering.rb', line 65 def show(page,={}) erb(page,) end |
#yaml(obj) ⇒ String
Renders a YAML blob and sets the content-type accordingly.
104 105 106 107 108 |
# File 'lib/wsoc/helpers/rendering.rb', line 104 def yaml(obj) content_type :yaml return YAML.dump(obj) end |