3

Building a website using erlang YAWS webserver. To generate dynamic content we have to embed erlang code within tags in ".yaws" page, which I feel is not best choice. I am aware of Nitrogen project, but I am not fond of proprietary solution.

Could anyone recommend better UI solution and example with YAWS as webserver?

curiosity
  • 73
  • 3

4 Answers4

1

You don't have to use the tags if you don't want too. You can also use an appmod in which case all requests to a directory will be routed to the out/1 function of a named module.

If you want to do more complex markup you can use EHTML from yaws or use ErlyDTL which gives you python style Django templates in Erlang.

If you want more on how to Do web applications in Erlang please have a look at my book Building Web Applications with Erlang now in Early release but should be in final release real soon now.

Zachary K
  • 3,205
  • 1
  • 29
  • 36
  • I did use appmod. But the HTML code have to generated in erlang module. Isn't it? I would like keep HTML separate from erlang code. – curiosity Apr 27 '12 at 15:17
  • Besides ErlyDTL, you can also take a look at [Mustache.erl](https://github.com/mojombo/mustache.erl) "a framework-agnostic templating system that enforces separation of view logic from the template file." – toraritte Aug 15 '15 at 16:37
1

You can use an appmod in Yaws.

The out function within an appmod module has the same semantic as in yaws page. You can then use the native Yaws Service Side Include system to keep your html code appart from your erlang code, if you want to.

Bernard Notarianni
  • 909
  • 1
  • 5
  • 13
0

How about sgte?

sgte is an Erlang template Engine for generating structured output (code, html web pages, xml, emails, csv files, etc...).

It's inspired on the StringTemplate template language. And tries to enforce strict separation between model and view. The template language tries to remain as simple as possible.

It's pretty basic, I know, but templates generally don't have to use much logic. Hadn't use it myself, though, but should give a try someday. )

raina77ow
  • 103,633
  • 15
  • 192
  • 229
0

You could have a look to ErlyDTL, an Erlang implementation of the Django Templating language.

Roberto Aloi
  • 30,570
  • 21
  • 75
  • 112
  • 2
    Thanks. I am looking at it as of now. Could you share, If you have any handy articles on how to use with YAWS? – curiosity Apr 27 '12 at 15:25