NITRO

INTRO

The refined SYNRC API of the Nitrogen Web Framework brought to us by Rusty Klophaus.

API

q(atom()) -> term().

Retrieves from process dictionary by atom-key the value of client DOM element passed by over the network as #ev parameter

event(click) -> io:format("~p~n",[nitro:q(:name)]);

jse([] | binary()) -> [] | binary().

Performs JavaScript escaping for eval compatibility.

> nitro:jse(<<"Ім'я"/utf8>>). <<"Ім\\'я"/utf8>>

wire(list(#action{})) -> [].

Updates the process dictionary actions variable with the new list of records inhereted from #action. This process dictionary variable is a way data is passed from your event handlers into the output rendering pipeline. This is fixed by Nitrogen Web Framework API.

> nitro:wire([#alert{text="hello"}]). [] > get(actions). [#wire{ancestor = action, trigger = [], target = [], module = action_wire, actions = [#alert{ancestor = action, trigger = [], target = [], module = action_alert, actions = [], source = [], text = "hello"}], source = []}]

render(list(#action{} | #element{})) -> binary().

Renders HTML5 binary string by the record inhereted from #element.

> rr(nitro). [abbr,action,address,alert,api,area,article,aside,audio, author,b,base,bdi,bdo,bind,blockquote,body,br,button, calendar,canvas,caption,checkbox,cite,code,col,colgroup, color,command|...] > #element{}. #element{ancestor = element,id = [],module = undefined, delegate = [],validation = [],validate = [],actions = [], class = [],style = [],source = [],onmouseover = [], onkeypress = [],onchange = [],onkeyup = [],onkeydown = [], onclick = [],data_fields = [],aria_states = [],body = [], role = [],tabindex = [],show_if = true,html_tag = [], title = [],postback = [],accesskey = [], contenteditable = [],contextmenu = [],...} < nitro:render(#alert{text="hello"}). ["alert(\"","hello","\");"] > nitro:render(#element{}). [<<"<">>,<<"element">>, [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]], <<">">>,<<>>,<<"</">>,<<"element">>,<<">">>] > iolist_to_binary(nitro:render(#element{})). <<"<element></element>">> > iolist_to_binary(nitro:render(setelement(1,#element{},tag))). <<"<tag></tag>">>

insert_top(atom(), list(#element{})) -> [].

insert_bottom(atom(), list(#element{})) -> [].

update(atom(), list(#element{})) -> [].

clear(atom()) -> [].

remove(atom()) -> [].

Wires a JavaScript to the process dictionary that manipulate DOM elements tree directly on a client side.

display(atom(),atom()) -> [].

Wires a JavaScript that manipulate style field of a given DOM element.

compact(term()) -> binary().

Pretty-prints the term into more compact format to display by a recursive cut the tuples with no more that 9 elements width.

> iolist_to_binary(nitro:compact({1,2,3,4,5,{1,2,3,4},7,8,9,10,11})). <<"{1,2,3,4,5,{1,2,3,4},7,8,9}">>