?DEBUG and ?PRINT in Nitrogen (Erlang web framework)?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
10 views
Started to learn Erlang, downloaded and installed the web framework Nitrogen, started tutorial


Launched a page index.erl (there were difficulties, but he figured)
%% -*- mode: nitrogen -*- -module (index). -compile(export_all). -include_lib("nitrogen/include/wf.hrl"). main() -> #template { file="./site/templates/bare.html" }. title() -> "Welcome to my Website". body() -> #container_12 { body=[ #grid_8 { alpha=true, prefix=2, suffix=2, omega=true, body=inner_body() } ]}. inner_body() -> [ #h1 { text="Welcome to me" }, #p{ }, " If you can see this page, then your Nitrogen server is up and running. Click the button below to test postbacks. ", #p{}, #button { id=button, text="Click me!", postback=click }, #p{}, " Run ./bin/dev help to see some useful developer commands. " ]. event(click) -> wf:replace(button, #panel { body="You clicked the button!", actions=#effect { effect=highlight } }).



came in the tutorial, to the place
Debug Statements

Add ?DEBUG to index.erl. Then compile and reload. What happens?

Add ?PRINT(node()) to index.erl. Then compile and reload. What happens?



And do not try to add them, always gives a compilation error. The gugleniya showed that it is macros, but the examples of their practical use could not find.


Question: how to add code pages?
by | 10 views

1 Answer

0 like 0 dislike
For example:
\r
event(click) -> ?DEBUG wf:replace(button, #panel { body="You clicked the button!", actions=#effect { effect=highlight } }).

Will click, will receive a debug message to the console.
\r
Or this:
\r
inner_body() -> ?PRINT(node()), [ #h1 { text="Welcome to my ERL-TASTIC WEBSITE!" }, #p{}, " If you can see this page, then your Nitrogen server is up and running. Click the button below to test postbacks. ", #p{}, #button { id=button, text="Click me!", postback=click }, #p{}, " Run ./bin/dev help to see some useful developer commands. " ].

\r
There will be a message to the console each time you open the page, moreover, contain the name of the node.
by

Related questions

0 like 0 dislike
7 answers
asked Mar 22, 2019 by RuJet
0 like 0 dislike
4 answers
asked Mar 25, 2019 by Zona
0 like 0 dislike
7 answers
0 like 0 dislike
2 answers
asked Apr 13, 2019 by MDtox
110,608 questions
257,186 answers
0 comments
28,013 users