API
ELEMENTS
Nitrogen Elements is a HTML template engine for Erlang language where all HTML tags are being rendered from Erlang records.
With N2O you don’t need to use HTML at all. Instead you define your page in the form of Erlang records so that the page is type checked at the compile time. This is a classic CGI approach for compiled pages and it gives us all the benefits of compile time error checking and provides DSL for client and server-side rendering.
Nitrogen elements, by their nature, are UI control primitives that can be used to construct Nitrogen pages with Erlang internal DSL. They are compiled into HTML and JavaScript. Behavior of all elements is controlled on server-side and all the communication between browser and server-side is performed over WebSocket channels. Hence there is no need to use POST requests or HTML forms. I.e.
will produce
- nx_textbox — HTML TextBox
- nx_input — HTML Input
- nx_textarea — HTML TextArea
- nx_th — HTML Table Header
- nx_tr — HTML Table Row
- nx_table — HTML Table
- nx_select — HTML Select
- nx_button — HTML Button
- nx_fieldset — HTML Fieldset
- nx_image — HTML Image
- nx_label — HTML Label
- nx_radio — HTML RadioButton
- nx_password — HTML Password
- nx_upload — NX Upload
- nx_calendar — NX Calendar
- nx_comboLookup — NX ComboLookup
- nx_dtl — DTL Django
ACTIONS
Nitrogen Actions is a JavaScript template engine for Erlang language where all events and button reactions are being rendered from Erlang language.
This will produce the following HTML:
and JavaScript code:
- action_bind — JavaScript Bind
- action_confirm — JavaScript Confirm
- action_event — JavaScript Postback Event
SPEC
NITRO supports streaming of prerendered forms over WebSocket and MQTT and provides tiny JavaScript library to work with document model. This library is compatible across implementations.