It's very simple, just call the function like you would normally do in Erlang programs, i.e. Module:func_name(arguments)
the only thing you need to do is make sure Yaws knows where to find the compiled BEAM file. In the Yaws configuration file add:
ebin_dir = /tmp/ebin
Compile your utilities.erl
, put the BEAM file in /tmp/ebin
and you can call your utility functions from the webpage.yaws
file.
Full example:
website.yaws:
<html>
<erl>
out(Arg) ->
D=utilities:get_some_strings(),
{html, ["Retrieved from utilities: ", D]}.
</erl>
</html>
utilities.erl:
-module(utilities).
-export([get_some_strings/0]).
get_some_strings() ->
"hello world!".