Skip to content

Instantly share code, notes, and snippets.

@si14
Created October 17, 2011 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save si14/7229a3b39bb2ac603523 to your computer and use it in GitHub Desktop.
Save si14/7229a3b39bb2ac603523 to your computer and use it in GitHub Desktop.
%% -*- mode: nitrogen -*-
-module (test).
-compile(export_all).
-include_lib("nitrogen_core/include/wf.hrl").
-include("records.hrl").
main() -> #template { file="./site/templates/bare.html" }.
title() -> "Hello from test.erl!".
body() ->
wf:comet(fun() -> counter(1) end),
[
#panel { style="margin: 50px 100px;", body=[
#span { text="Hello from test.erl!" },
#p{},
#button { text="Click me!", postback=click },
#p{},
#panel { id=placeholder }
]}
].
event(click) ->
wf:insert_top(placeholder, "<p>You clicked the button!!").
counter(Count) ->
?PRINT(Count),
timer:sleep(1000),
wf:insert_bottom(p_messages, integer_to_list(Count) ++ "<br>"),
wf:flush(),
counter(Count + 1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment