tcl-websh-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (David N. Welton)
Subject putx substition style
Date Thu, 20 Dec 2001 21:28:52 GMT

I have been looking at the putx code, and wondering about the
suggestion to change it to a group of 'put' statements interspersed
with code to eval.

It's a good idea (mod_dtcl is based around it:-)...

My current thinking on the situation is that there are two good ways
to mix up Tcl and HTML.

1) Using <? ?> (as per )

   This is the proper way to do 'processing instructions' for XML.  I
   regard this model as the 'full integration' model, because it lets
   you add things quite naturally to an HTML document, and also
   because it's necessary - at least if you want to be able to loop or
   do conditionals on chunks of HTML outside the <? ?> - to add
   everything up as either bits to execute or 'puts' statements.

2) Substitution, using 'subst' on the text directly.

   This is more immediate, and quicker if one just wants to substitute
   some variable values (possibly having taken care of the logic

I would encourage future directions to take after both of these, as
they both have their uses, and to discourage other systems (for
instance, ASP style delimiters, {}, <+, or whatever else).

By the way, what is to be gained from using {} instead of just

web::put " [something blah] ...." ?

For instance:

        web::putx {
            <h1>Top secret session information</h1>
            <dd>{web::put [web::statef::id]}
            <dd>{web::put [web::statef::get name]}
            <dd>{web::put [web::statef::get age]}

Could be 

        web::put [subst {
            <h1>Top secret session information</h1>
            <dd>[web::statef::get name]
            <dd>[web::statef::get age]

The [subst uglifies it a bit, but in reality, you don't even need that
if you just use "" instead of "" (knowing you have to escape the

Personally, I am happier when I can rely on native Tcl functionality
to do things for me.

David N. Welton
Free Software:
   Apache Tcl:

View raw message