z_render (zotonic_core v1.0.0-rc.11)

Render routines using wires and actions. Based on Nitrogen, which is copyright (c) 2008-2009 Rusty Klophaus

Link to this section Summary

Functions

Set the contents of an element to the the html fragment
Add a html after the target element
Append a html fragment at the bottom of the contents of an element
Append a html fragment at the bottom of the contents of an element
Insert a html fragment at the top of the contents of an element
Remove all scripts from the context, resetting it back to a clean sheet.
Map a target id to a css selector
Map a target id to a css selector, check the Args proplist for additional selectors
Collect all scripts in the context, returns an iolist with javascript.
Add a html after the target element
Add a html before the target element
Append a html fragment at the bottom of the contents of an element
Insert a html fragment at the top of the contents of an element
Make a javascript to call the postback, posting an encoded string containing callback information. The PostbackTag is send to the server, EventType is normally the atom 'postback'.
Make an encoded string containing information which module and function to call.
Replace the placeholders with their rendered content and collect all scripts from the mixed html and context. The result is a clean HTML tree and can be used for return by controllers.
Quote a css selector (assume no escaping needed...)
Render adds output to the render-state of the context. Makes sure that the added output is an iolist The stored render state is later used in output/2
Render a css selector, allow direct expressions like
Render adds output to the render field of the context state. Do update the context for possible changes in scripts etc.
Render a validator to the correct javascript. Args are all arguments of the validator scomp. This renders an allocation of the initial validator and then appends all validations. 'type' holds multiple validations. Validations are of the form: {validator, [Args]}
Replace an element to the the html fragment
Set the value of an input element.
Set the contents of an element to the the html fragment
Set the contents of an iframe to the generated html.
Set the contents of all elements matching the css selector to the the html fragment
Set the contents of all elements matching the css selector to the the html fragment
Add an input validator to the list of known validators, used when rendering custom validators

Link to this section Types

-type ctx_rs() :: render_state() | z:context().
Link to this type

html_element_id/0

-type html_element_id() :: binary() | string() | undefined.
Link to this type

render_state/0

-type render_state() :: #render_state{}.

Link to this section Functions

Link to this function

add_script(Script, Context)

Link to this function

appear(TargetId, Html, Context)

Set the contents of an element to the the html fragment
Link to this function

appear_after(TargetId, Html, Context)

Add a html after the target element
Link to this function

appear_after_selector(CssSelector, Html, Context)

Link to this function

appear_after_selector_js(CssSelector, Html)

Link to this function

appear_before(TargetId, Html, Context)

Append a html fragment at the bottom of the contents of an element
Link to this function

appear_before_selector(CssSelector, Html, Context)

Link to this function

appear_before_selector_js(CssSelector, Html)

Link to this function

appear_bottom(TargetId, Html, Context)

Append a html fragment at the bottom of the contents of an element
Link to this function

appear_bottom_selector(CssSelector, Html, Context)

Link to this function

appear_bottom_selector_js(CssSelector, Html)

Link to this function

appear_replace(TargetId, Html, Context)

Link to this function

appear_replace_selector(CssSelector, Html, Context)

Link to this function

appear_replace_selector_js(CssSelector, Html)

Link to this function

appear_selector(CssSelector, Html, Context)

Link to this function

appear_selector_js(CssSelector, Html)

Link to this function

appear_top(TargetId, Html, Context)

Insert a html fragment at the top of the contents of an element
Link to this function

appear_top_selector(CssSelector, Html, Context)

Link to this function

appear_top_selector_js(CssSelector, Html)

-spec clean(z:context()) -> z:context().
Remove all scripts from the context, resetting it back to a clean sheet.
Link to this function

css_selector(TargetId)

Map a target id to a css selector
Link to this function

css_selector(TargetId, Args)

Map a target id to a css selector, check the Args proplist for additional selectors
Link to this function

dialog(Title, Template, Vars, Context)

Link to this function

dialog_close(Context)

Link to this function

get_script(Context)

-spec get_script(z:context()) -> iolist().
Collect all scripts in the context, returns an iolist with javascript.
Link to this function

growl(Text, Context)

Link to this function

growl(Text, Type, Stay, Context)

Link to this function

growl_error(Text, Context)

Link to this function

insert_after(TargetId, Html, Context)

Add a html after the target element
Link to this function

insert_after_selector(CssSelector, Html, Context)

Link to this function

insert_after_selector_js(CssSelector, Html)

Link to this function

insert_before(TargetId, Html, Context)

Add a html before the target element
Link to this function

insert_before_selector(CssSelector, Html, Context)

Link to this function

insert_before_selector_js(CssSelector, Html)

Link to this function

insert_bottom(TargetId, Html, Context)

Append a html fragment at the bottom of the contents of an element
Link to this function

insert_bottom_selector(CssSelector, Html, Context)

Link to this function

insert_bottom_selector_js(CssSelector, Html)

Link to this function

insert_top(TargetId, Html, Context)

Insert a html fragment at the top of the contents of an element
Link to this function

insert_top_selector(CssSelector, Html, Context)

Link to this function

insert_top_selector_js(CssSelector, Html)

Link to this function

make_postback(PostbackTag, EventType, TriggerId, TargetId, Delegate, Context)

Make a javascript to call the postback, posting an encoded string containing callback information. The PostbackTag is send to the server, EventType is normally the atom 'postback'.
Link to this function

make_postback(PostbackTag, EventType, TriggerId, TargetId, Delegate, QArgs, Context)

Link to this function

make_postback_info(Tag, EventType, TriggerId, TargetId, Delegate, Context)

Make an encoded string containing information which module and function to call.
Link to this function

make_validation_postback(Validator, Context)

Link to this function

make_validation_postback(Validator, Args, Context)

Link to this function

output(MixedHtml, Context)

-spec output(term(), z:context()) -> {iolist(), z:context()}.
Replace the placeholders with their rendered content and collect all scripts from the mixed html and context. The result is a clean HTML tree and can be used for return by controllers.
Link to this function

overlay(Template, Vars, Context)

Link to this function

overlay_close(Context)

Link to this function

quote_css_selector(S)

Quote a css selector (assume no escaping needed...)
Link to this function

render(Mixed, Context)

-spec render(term(), z:context()) -> z:context().
Render adds output to the render-state of the context. Makes sure that the added output is an iolist The stored render state is later used in output/2
Link to this function

render_actions(TriggerId, TargetId, T, Context)

-spec render_actions(html_element_id(), html_element_id(), list(), z:context()) ->
                  {iolist(), z:context()}.
Link to this function

render_css_selector(Selector)

Render a css selector, allow direct expressions like
Link to this function

render_html(Render, Context)

Link to this function

render_to_iolist(MixedHtml, Context)

-spec render_to_iolist(MixedHtml :: term(), z:context()) -> {iolist(), z:context()}.
Render adds output to the render field of the context state. Do update the context for possible changes in scripts etc.
Link to this function

render_to_iolist(Template, Vars, Context)

-spec render_to_iolist(Template :: term(), list(), z:context()) -> {iolist(), z:context()}.
Link to this function

render_validator(TriggerId, TargetId, Args, Context)

-spec render_validator(undefined | binary(), undefined | binary(), list(), z:context()) -> iolist().
Render a validator to the correct javascript. Args are all arguments of the validator scomp. This renders an allocation of the initial validator and then appends all validations. 'type' holds multiple validations. Validations are of the form: {validator, [Args]}
Link to this function

replace(TargetId, Html, Context)

Replace an element to the the html fragment
Link to this function

replace_selector(CssSelector, Html, Context)

Link to this function

replace_selector_js(CssSelector, Html)

Link to this function

set_value(TargetId, Value, Context)

Set the value of an input element.
Link to this function

set_value_selector(CssSelector, Value, Context)

Link to this function

update(TargetId, Html, Context)

-spec update(string() | binary(), #render{} | iodata(), z:context()) -> z:context().
Set the contents of an element to the the html fragment
Link to this function

update_iframe(IFrameId, Html, Context)

Set the contents of an iframe to the generated html.
Link to this function

update_selector(CssSelector, Html, Context)

Set the contents of all elements matching the css selector to the the html fragment
Link to this function

update_selector_js(CssSelector, Html)

Set the contents of all elements matching the css selector to the the html fragment
Link to this function

validator(TriggerId, TargetId, Validator, Context)

Add an input validator to the list of known validators, used when rendering custom validators
Link to this function

wire(Actions, Context)

-spec wire(tuple() | [tuple()], ctx_rs()) -> ctx_rs().
Link to this function

wire(TriggerId, Actions, Context)

Link to this function

wire(TriggerId, TargetId, Actions, Context)