Module z_render

Render routines using wires and actions.

Copyright © 2009-2021 Marc Worrell

Authors: Marc Worrell (marc@worrell.nl), Rusty Klophaus.

Description

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

Data Types

ctx_rs()

ctx_rs() = render_state() | z:context()

html_element_id()

html_element_id() = binary() | string() | undefined

render_state()

render_state() = #render_state{updates = list(), actions = list(), content_scripts = list(), scripts = list(), wire = list(), validators = list(), render = list()}

Function Index

add_script/2
appear/3Set the contents of an element to the the html fragment.
appear_after/3Add a html after the target element.
appear_after_selector/3
appear_after_selector_js/2
appear_before/3Append a html fragment at the bottom of the contents of an element.
appear_before_selector/3
appear_before_selector_js/2
appear_bottom/3Append a html fragment at the bottom of the contents of an element.
appear_bottom_selector/3
appear_bottom_selector_js/2
appear_replace/3
appear_replace_selector/3
appear_replace_selector_js/2
appear_selector/3
appear_selector_js/2
appear_top/3Insert a html fragment at the top of the contents of an element.
appear_top_selector/3
appear_top_selector_js/2
clean/1Remove all scripts from the context, resetting it back to a clean sheet.
css_selector/1Map a target id to a css selector.
css_selector/2Map a target id to a css selector, check the Args proplist for additional selectors.
dialog/4
dialog_close/1
get_script/1Collect all scripts in the context, returns an iolist with javascript.
growl/2
growl/4
growl_error/2
insert_after/3Add a html after the target element.
insert_after_selector/3
insert_after_selector_js/2
insert_before/3Add a html before the target element.
insert_before_selector/3
insert_before_selector_js/2
insert_bottom/3Append a html fragment at the bottom of the contents of an element.
insert_bottom_selector/3
insert_bottom_selector_js/2
insert_top/3Insert a html fragment at the top of the contents of an element.
insert_top_selector/3
insert_top_selector_js/2
make_postback/6Make a javascript to call the postback, posting an encoded string containing callback information.
make_postback/7
make_postback_info/6Make an encoded string containing information which module and function to call.
make_validation_postback/2
make_validation_postback/3
output/2Replace the placeholders with their rendered content and collect all scripts from the mixed html and context.
overlay/3
overlay_close/1
quote_css_selector/1Quote a css selector (assume no escaping needed...).
render/2Render adds output to the render-state of the context.
render_actions/4
render_css_selector/1Render a css selector, allow direct expressions like.
render_html/2
render_to_iolist/2Render adds output to the render field of the context state.
render_to_iolist/3
render_validator/4Render a validator to the correct javascript.
replace/3Replace an element to the the html fragment.
replace_selector/3
replace_selector_js/2
set_value/3Set the value of an input element.
set_value_selector/3
update/3Set the contents of an element to the the html fragment.
update_iframe/3Set the contents of an iframe to the generated html.
update_selector/3Set the contents of all elements matching the css selector to the the html fragment.
update_selector_js/2Set the contents of all elements matching the css selector to the the html fragment.
validator/4Add an input validator to the list of known validators, used when rendering custom validators.
wire/2
wire/3
wire/4

Function Details

add_script/2

add_script(Script, Context) -> any()

appear/3

appear(TargetId, Html, Context) -> any()

Set the contents of an element to the the html fragment

appear_after/3

appear_after(TargetId, Html, Context) -> any()

Add a html after the target element

appear_after_selector/3

appear_after_selector(CssSelector, Html, Context) -> any()

appear_after_selector_js/2

appear_after_selector_js(CssSelector, Html) -> any()

appear_before/3

appear_before(TargetId, Html, Context) -> any()

Append a html fragment at the bottom of the contents of an element

appear_before_selector/3

appear_before_selector(CssSelector, Html, Context) -> any()

appear_before_selector_js/2

appear_before_selector_js(CssSelector, Html) -> any()

appear_bottom/3

appear_bottom(TargetId, Html, Context) -> any()

Append a html fragment at the bottom of the contents of an element

appear_bottom_selector/3

appear_bottom_selector(CssSelector, Html, Context) -> any()

appear_bottom_selector_js/2

appear_bottom_selector_js(CssSelector, Html) -> any()

appear_replace/3

appear_replace(TargetId, Html, Context) -> any()

appear_replace_selector/3

appear_replace_selector(CssSelector, Html, Context) -> any()

appear_replace_selector_js/2

appear_replace_selector_js(CssSelector, Html) -> any()

appear_selector/3

appear_selector(CssSelector, Html, Context) -> any()

appear_selector_js/2

appear_selector_js(CssSelector, Html) -> any()

appear_top/3

appear_top(TargetId, Html, Context) -> any()

Insert a html fragment at the top of the contents of an element

appear_top_selector/3

appear_top_selector(CssSelector, Html, Context) -> any()

appear_top_selector_js/2

appear_top_selector_js(CssSelector, Html) -> any()

clean/1

clean(Context::z:context()) -> z:context()

Remove all scripts from the context, resetting it back to a clean sheet.

css_selector/1

css_selector(TargetId) -> any()

Map a target id to a css selector

css_selector/2

css_selector(TargetId, Args) -> any()

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

dialog/4

dialog(Title, Template, Vars, Context) -> any()

dialog_close/1

dialog_close(Context) -> any()

get_script/1

get_script(Context::z:context()) -> iolist()

Collect all scripts in the context, returns an iolist with javascript.

growl/2

growl(Text, Context) -> any()

growl/4

growl(Text, Type, Stay, Context) -> any()

growl_error/2

growl_error(Text, Context) -> any()

insert_after/3

insert_after(TargetId, Html, Context) -> any()

Add a html after the target element

insert_after_selector/3

insert_after_selector(CssSelector, Html, Context) -> any()

insert_after_selector_js/2

insert_after_selector_js(CssSelector, Html) -> any()

insert_before/3

insert_before(TargetId, Html, Context) -> any()

Add a html before the target element

insert_before_selector/3

insert_before_selector(CssSelector, Html, Context) -> any()

insert_before_selector_js/2

insert_before_selector_js(CssSelector, Html) -> any()

insert_bottom/3

insert_bottom(TargetId, Html, Context) -> any()

Append a html fragment at the bottom of the contents of an element

insert_bottom_selector/3

insert_bottom_selector(CssSelector, Html, Context) -> any()

insert_bottom_selector_js/2

insert_bottom_selector_js(CssSelector, Html) -> any()

insert_top/3

insert_top(TargetId, Html, Context) -> any()

Insert a html fragment at the top of the contents of an element

insert_top_selector/3

insert_top_selector(CssSelector, Html, Context) -> any()

insert_top_selector_js/2

insert_top_selector_js(CssSelector, Html) -> any()

make_postback/6

make_postback(PostbackTag, EventType, TriggerId, TargetId, Delegate, Context) -> {JavascriptString, PickledPostback}

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_postback/7

make_postback(PostbackTag, EventType, TriggerId, TargetId, Delegate, QArgs, Context) -> any()

make_postback_info/6

make_postback_info(Tag, EventType, TriggerId, TargetId, Delegate, Context) -> any()

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

make_validation_postback/2

make_validation_postback(Validator, Context) -> any()

make_validation_postback/3

make_validation_postback(Validator, Args, Context) -> any()

output/2

output(MixedHtml::term(), Context::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.

overlay/3

overlay(Template, Vars, Context) -> any()

overlay_close/1

overlay_close(Context) -> any()

quote_css_selector/1

quote_css_selector(S) -> any()

Quote a css selector (assume no escaping needed...)

render/2

render(Mixed::term(), Context::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

render_actions/4

render_actions(TriggerId::html_element_id(), TargetId::html_element_id(), T::list(), Context::z:context()) -> {iolist(), z:context()}

render_css_selector/1

render_css_selector(Selector) -> any()

Render a css selector, allow direct expressions like

render_html/2

render_html(Render, Context) -> any()

render_to_iolist/2

render_to_iolist(MixedHtml::term(), Context::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.

render_to_iolist/3

render_to_iolist(Template::term(), Vars::list(), Context::z:context()) -> {iolist(), z:context()}

render_validator/4

render_validator(TriggerId::undefined | binary(), TargetId::undefined | binary(), Args::list(), Context::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]}

replace/3

replace(TargetId, Html, Context) -> any()

Replace an element to the the html fragment

replace_selector/3

replace_selector(CssSelector, Html, Context) -> any()

replace_selector_js/2

replace_selector_js(CssSelector, Html) -> any()

set_value/3

set_value(TargetId, Value, Context) -> any()

Set the value of an input element.

set_value_selector/3

set_value_selector(CssSelector, Value, Context) -> any()

update/3

update(TargetId::string() | binary(), Html::#render{} | iodata(), Context::z:context()) -> z:context()

Set the contents of an element to the the html fragment

update_iframe/3

update_iframe(IFrameId, Html, Context) -> any()

Set the contents of an iframe to the generated html.

update_selector/3

update_selector(CssSelector, Html, Context) -> any()

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

update_selector_js/2

update_selector_js(CssSelector, Html) -> any()

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

validator/4

validator(TriggerID::string(), TargetID::string(), Validator::#validator{}, Context::#context{}) -> #context{}

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

wire/2

wire(Actions::tuple() | [tuple()], Context::ctx_rs()) -> ctx_rs()

wire/3

wire(TriggerId, Actions, Context) -> any()

wire/4

wire(TriggerId, TargetId, Actions, Context) -> any()


Generated by EDoc