assfish

Documentation
Login

Here is a .assf file that does a little bit more.

<% is the Open tag to enter a tcl command.
<%= is the open tag to cause the output of the following tcl command to be returned to the HTML document.

For instance, <%= $hello %> will cause the contents of the variable hello to be added to the HTML.

Any special characters will be escaped.

There is a special form of the open tag that will skip the escaping of any text. <%== $html_var %> will cause the value of html_var to be directly placed into the html page. It can be used if you have a function that generates properly escaped HTML.

The following example page shows a few different ways of escaping your text. The very first line of the document is a tcl comment that doesn't do anything.

<%## does it work if first line of file is a tcl script?
%><!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Assfish sample form entry page</title>
  </head>

  <body>

    <div class="navbar navbar-inverse navbar-fixed-top">
        <!--  
            notice use of inline style here.
            not sure about why.. but navbar-inner has a 5px border, which causes the screen
            to act flakey when the width changes and it flips from showing the headers to showing the drop down icon
        -->
<div class="container">
<br>

Right now is <%= [clock format [clock seconds]]%>.
<br>

[try lots of \n weird tcl {commands here....

this should not show directory. [pwd].  or $var foo $zot

<%
## another bit of danger...
## creating procs inside of another proc.
## uses namespace instead of proc to divide all the
## stuff up... namespace eq the filename. 
## check out <a href="subst_file2.assf">subst_file2.assf</a> to see
## how the procedure 'me' is only available from subst-file1.assf namespace
##

proc me {args} {
    %>  

        Inside of Me.  args= <%= $args %>  and more.
    
       <OL> 
            <LI> ME LI1 </LI>
            <LI> ME LI2 </LI>
            <LI> ME LI3 </LI>
        </OL>

<% 
}

proc < {} {
    ## who would create a proc named <??
}

proc & {} {
    ## even funnier...
}

%>


<ul>
    <% for {set x 0} {$x < 5} {incr x} {  %> 
    <% ## you need two equal signs below to keep
       ## assfish from escaping the <li> stuff.  %>
    <%== [format "<li>  <em> the Magical x =</em> %s" $x]  %>
    <!-- 
    <li> x= <%= $x %>
    -->
    <% } %>
</ul>

X ended up being = to <%=$x%> <br>
<%
    ## we make a call to the "me" proc below.  me was defined to return
    ## HTML, so we need to use == to keep it from being escaped twice.
%>
I'm currently in directory <%=[pwd]%>  me = <%==[me one two three $x]%> <br>

<%= [join [glob -nocomplain *] ", "]%> <br>
<br>

Current Commands: <br>
<UL>
<% foreach command [lsort [info commands]] { %>
    <LI> <%= $command%>
<% } %>

</UL>

<% ## does it work if last line is a tcl script 
%>
</div>
</body>
</html>