Erlang Programming/Creating Web Applications with yaws/First Yaws Webapp
Appearance
Files using the file ending suffix ".yaws" will be processed by Yaws dynamic compiler where embedded Erlang code can be written amongst the HTML, as such:
<html>
<erl>
out(Arg) ->
{html, "<h1>Hello world.</h1>"}.
</erl>
</html>
When a .yaws file is processed by Yaws, the dynamic compiler in Yaws will single out any <erl> tags, compile the erlang code contained within an <erl> tag and cache the compiled resulting binary. Yaws will then during the execution of the Erlang code call the function out/1 in each binary with the Arg data structure supplied as the parameter and output the results. In this case, because out/1 returns to Yaws the tuple {html, String}, Yaws will assume the String is html and forward the String to the client.