annotate framework/env/slot/set_layout.lua @ 538:8bb8f08d1d55
Fixed wrongly committed .hgtags file
 | author | jbe | 
 | date | Tue Apr 02 00:01:16 2019 +0200 (2019-04-02) | 
 | parents | 6c819040ef6f | 
 | children |  | 
 
 | rev | line source | 
| jbe/bsw@0 | 1 --[[-- | 
| jbe/bsw@0 | 2 slot.set_layout( | 
| jbe/bsw@0 | 3   layout_ident,   -- name of layout or nil for binary data in slot named "data" | 
| jbe/bsw@0 | 4   content_type    -- content-type to be sent to the browser, or nil for default | 
| jbe/bsw@0 | 5 ) | 
| jbe/bsw@0 | 6 | 
| jbe@494 | 7 This function selects which layout should be used when calling slot.render_layout() (as done by request.handler(...)). If nil is selected as layout, then no layout will be used, but the slot named "data" is used plainly. The second argument to slot.set_layout is the content-type which is sent to the browser. | 
| jbe@494 | 8 | 
| jbe@509 | 9 The default layout for views is "default" (but errors get a default layout named "system_error"). Actions have no default layout, but an explicit call of slot.set_layout(...) (even with nil as first argument) during request handling will cause subsequent calls of slot.layout_is_set() to return true which indicates that content (e.g. via slot.put_into("data", ...)) is available and should be rendered instead of using the action's return value to forward or redirect the user agent. | 
| jbe/bsw@0 | 10 | 
| jbe/bsw@0 | 11 --]]-- | 
| jbe/bsw@0 | 12 | 
| jbe/bsw@0 | 13 function slot.set_layout(layout_ident, content_type) | 
| jbe@262 | 14   request.configure(function() | 
| jbe@262 | 15     slot._current_layout = layout_ident | 
| jbe@262 | 16     slot._content_type = content_type | 
| jbe@262 | 17   end) | 
| jbe@493 | 18   if request.is_in_progress() then | 
| jbe@493 | 19     slot._layout_set = true | 
| jbe@493 | 20   end | 
| jbe/bsw@0 | 21 end |