Here's a first draft in Rails that doesn't use any template files.
class HomeController < ApplicationController
def first
if request.get?
aform 'first', [input('foo'), submit]
else
session[:foo] = params[:foo]
wlink 'third', 'click here'
end
end
def third
pr "you said: #{session[:foo]}"
end
end
A small example is fine, but wouldn't it be better if it at least did some basic validation? How does the Arc example change if you enforce only alphanumeric characters in the input field?
class HomeController < ApplicationController
def first
if request.get?
aform 'first', [input('foo'), submit]
else
if params[:foo] && params[:foo] =~ /[A-Za-z0-9]/
session[:foo] = params[:foo]
wlink 'third', 'click here'
else
aform 'first', ["Please enter an alphanumeric string", input('foo'), submit]
end
end
end
def third
pr "you said: #{session[:foo]}"
end
end
Of course, we'll then want to allow the designers to modify the presentation, and allow the copy writers to add compelling text, etc. So, it seems like a template system is the way to go, but maybe someone has a better idea.
I can see pros/cons of a template based approach vs. generating everything. I do find the separation of templates from code to be very beneficial since I haven't been able to get to the point of controlling 100% of the presentation via CSS alone - sometimes a simple structural change in a template file is less intrusive than modifying code.
Also, I wonder about the overhead of continuation based approaches with higher volumes.