The source for the shopping cart

The shoppingcart contains a number of tricks and "preferred" ways to
code different typical solutions to servers side state applications.
The source itself resides in the www/shoppingcart directory in the
source code tree. A link to the source itself to view from
the browser.

The first trick, the break statement

The source of all yaws pages (including example index.yaws)
look very similar in this application, specifically

All code, including the head containing the link
to the stylesheet is dynamically
generated. The first function in all code snippets in yaws files is always
a call to shopcart:top(A)

The top/1 function will check the cookie and if a cookie
which is associated to an active session is found, the request is granted,
otherwise the login page is displayed by the shopcart:login(A) function.

The last item displayed by the login function is the atom break. When the
yaws server sees the break, it will not process any more data from the
yaws page being requested. Thus, we can have the login call at the top of a yaws
page and still have subsequent html/yaws code on the same page.

Redirect to the requested page

Since the login(A) function is supplied with the
Arg of the requested page, the login function
will set the path of the requested page in a hidden field in the login form.
The code that processes the login form will then issue a redirect to the
value of this hidden field if the login in successful.

Ehtml

The use of the ehtml output syntax makes it more convenient to dynamically
generate structured content:

It is easier to get the structure right,

It
is easier to inject the dynamically generated parts in the structure,