Mail archive

[Acf] RFC: less lua - more html

From: Natanael Copa <>
Date: Sat, 14 Oct 2006 02:11:03 +0200


I mentioned earlier to Nathan that I have some ideas how to try to
simplify the current mvc implemntation.

The problem with curent implementation is that you write a html page in

m = model.hostname
return { type="form", action="hostname.cgi", value= {
        { type="formtext", value="Set the hostname with this form" },
        { type="text", name="hostname", value=m.get() },
        { type="submit", name="cmd", value="Set hostname" }

Compare that with:

<? c = controller.hostname ?>
<form action="hostname.cgi">
        <p>Set the hostname with this form</p>
        <input type="text" name="hostname" value="<? hostname.get() ?>"/>
        <input type="submit" name="cmd" value="Set hostname"/>

So basicly, the view is just moved over to the controller.

Now the limit between the view and the controller is not so big since we
are talking about html controllers here.

Now, people tend to be more familiar with html than lua, so it would be
better to try minimizing the lua code and replace it with html as much
as possible.

It is not desireable to write all html code again. Headers, footers
menus and maybe even tabs can be generated. What is interesting is what
is between <div id="content> and </div>.

We could let the generic.view do what it does now, but if there is a
file named foo.view.content, generic.view will do a haserl include
<?include foo.view.content ?>

This means that you dont need to write *all* the view, only the
interesting part in html. (I looked earlier how this could be
implemented and i think its possible)

The foo.view.content could look something like:

<? c = controller.hostname_form ?>
<form name="hostname_form" action="hostname.cgi">
        <p>Set the hostname with this form</p>
        <? html.input( c.hostname ) ?>
        <? html.input( c.cmd ) ?>

Where controller.hostname_form earlier is set to:

controller.hostname_form = Form:new()

        { type = "text", name="hostname", value=m.get() },
        { type ="submit", name="cmd", value="Set hostname" }

We could move things like labels and fromtext, from the controller to
the view. People could make the page structure in html instead of in

PS. While writing this, I'm not sure if this is what we really want. If
you do gui programming (qt, wxWigets, gtk) the labels are normally
controllers too.

Natanael Copa
Received on Sat Oct 14 2006 - 02:11:03 UTC