Yaws API discussion

Eric Merritt <>
Mon Jul 15 19:14:23 CEST 2002


 Per your request I am going to make a few
suggestions. I would, however, warn readers that I
will be swimming in what some consider a holy war
area. I do not intend any kind of little war here, I
am just providing suggestions based on my experience
and knowlege.

I believe that the problem you are having stems from a
core problem with the paradigm yaws has adopted. Yaws,
like PHP and JSP Scriptlets, is founded upon the idea
that actual logic should be embedded in the html page.
This is a bad thing(TM). It limits scalability of the
application by quite a bit. I am not refering to
scalability in terms of speed or performance, but to
scalablity in terms of application size,
reliablity/maintenance, and extensablility. 

I am rambling here so forgive me. Back in the early
'80s users of smalltalk realized that the ui design
paradigms of the time were lacking for large projects.
To address the issue they came up with a paradigm
called MVC (Model, View, Controller). This basically
stated that your model (data, logic) should be
seperated from your controller (flow control logic)
and all of that should be seperated from your view
code. It eventually was expoused that the view code
should be extreamly limited. In that it only allows
you to manipulate data provided from your model layer.

This was a really good idea for UIs, and when the WEB
came about it proved to be a really good idea for
webapplications as well.

 To use some hisorical examples, the inventors of JSP
realized this same issue after they released the first
JSP specification. In that original specification JSPs
allowed only scriptlets (which is java code imbedded
in the html and delimited by <% %> tags). This
approach was obviously not MVC like in any way. In
fact, it cuased quite allot of headaches for
developers then (and even in somecases now). Thier
next release included the idea of 'TagLibs' which are
custom tags that use data from provided from some
backend process (via session and request variables).
Now the use of scriptlets are frowned upon almost
universally and are actaully not allowed to be used in
most big projects. This still wasn't really a complete
MVC solution as the coder had to code allot of the
controller and logic framework himself, but it did
provide a foundation. Projects like Struts have made
good use of this foundation and provide full blown MVC
frameworks now. Using these frameworks has made web
application programming much much easier.

Well to get back to your problem. If your
Model/Controller layer only provided data to your view
and your view simply made use of that data all you
would need to do is include the header and it could
make use of all the data that was globally available
in the page. In JSPs that is simply an <@include 'page
location'> directive. The included page then simply
makes use of the data already provided.

I realize that the yaws api is based to quite a large
extent on PHP, but PHP is a very poor choice for
large, extensable applications. Don,t get me wrong PHP
is a great thing for quick and dirty applications.
Basically for those applications that only span a few
pages or that are only designed to live a short time.
Anything beyond that and PHP starts to fall down. 

I would suggest that you take a look at some of the
Java page rendering technology. They have allot of
experience in this type of thing by now. Probably
start out with the taglib stuff and then take a look
at Struts (available at jakarta.apache.org/struts).
Perhaps also take a look at webmacro
(www.webmacro.org) and velocity
(jakarta.apache.org/velocity). I personally like the
idea of taglibs and compiled pages (I think they are
much faster), but the template engines and thier
restricted data manipulation langauges are nice as

I guess I went kind of long, sorry. I also hope I did
not get anyone too angry.


---  wrote:
> Hello,
> I feel that there is a need to improve an aspect of
> yaws api.
> The ssi function can be used to include some
> external html template. My need is to be able to add
> some dynamic generated values (for example the title
> in the html header portion)
> I am thinking on the best way to do that. The most
> evident thing is to pass a dictionnary of
> substitution that needs to be  performed in the
> included file.
> I think it might not be interesting to implement
> nested evaluation of included files.
> What do you think ?
> Any clever idea ?
> -- 
> Mickaël Rémond
> http://www.erlang-fr.org/

Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes

More information about the erlang-questions mailing list