public
Fork of wycats/merb-core
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/technoweenie/merb-core.git
Search Repo:
wycats (author)
Wed Jan 16 01:14:53 -0800 2008
commit  c05737f5efca30138b703b907368f9ae32b1d880
tree    086eb611fff73354ac8d3a4f6473d8c5544d9d0a
parent  5715c043c0f0f1aa9b6fd0576733132210e759e9 parent  bcdcde92753fc728060d196c779b7ee5c7619c49
merb-core / NEW_RENDER_API
100644 52 lines (36 sloc) 1.499 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
## TEMPLATES
 
# Render an action
render :symbol
 
# Render a string
render "string"
 
# Render an object; will call to_#{content-type} on this if the default template is not found
display @obj
 
# Provide an alternative default thing to render; note that we can use strings here for template paths
# because strings would never fail and fallback to the @obj
display @obj, :symbol
display @obj, "full/path/to/template"
 
# Render a template
render_template "full/path/to/template"
 
# Render with a mime-type (same as render, but with added mime-type set)
render_json :symbol
render_json "string"
 
# Render nothing at all
render_nothing
 
# TEMPLATE OPTIONS (all functions above can use these options)
 
# :format can be used to override the mime-type arrived at via content-negotiation
render :symbol, :format => :xml
 
# :status can set the status that will be returned to the browser
render :symbol, :status => Successful::Accepted
# or
render :symbol, :status => 202
 
# :layout sets the layout to use; default: controller.to_path || :application; :none means no layout
render :symbol, :layout => :none
 
 
## PARTIALS
 
# Render a partial
partial :symbol
 
# Render a partial with an object (it will default to the local var "symbol" in the partial)
partial :symbol, :with => @object
partial :symbol, :with => @object, :as => "something"
 
# Render a partial with a collection of objects (same :as semantics)
partial :symbol, :with => [col, lec, tion]
partial :symbol, :with => [col, lec, tion], :as => "name"