On Mon, 4 Sep 2000, Perrin Harkins wrote:

> "Paul J. Lucas" wrote:
> >         And I still think that:
> > 
> >           <DIV CLASS="employee_info">
> >             Name: <SPAN CLASS="text::name">John Q. Public</SPAN><BR>
> >             Job: <SPAN CLASS="text::job">mod_perl guru</SPAN>
> >           </DIV>
> > 
> >         is cleaner still: *pure* HTML (no fake elements) that any web
> >         tool will understand and dummy-content so the page designer can
> >         see the end-product before any code is written.
> 
> Having placeholder data in there is an interesting benefit.

        I currently use the .chtml extension to tell Apache to do my
        magic (via <Files *.chtml>).  But I often do a:

                ln file.chtml file.html

        and then I can point my browser at the plain .html version when
        I want to see what the mock-up page looks like without executing
        any code.  In production, I remove the links.

> What about conditionals and loops though?

        I just got another e-mail about this so I could clarify.  There
        is no loop that you can see in my example, and this is by design
        since HTML doesn't loop.

        All of this is explained in the documentaion, but, briefly: the
        looping is done under the control of the associated .pm file:
        for every HTML file, there is an associated .pm file and that's
        where all the code is.

        The function bound to the class employee_info tells the HTML
        Tree engine that it wants to loop (or not loop) by its return
        code.

        An example of a conditional:

                <DIV CLASS="if::do_this">
                  blah
                </DIV>

        where do_this has to have been already evaluated and the result
        stuffed into $this->{ do_this }.  But, the "if::" is just a
        built-in class (to my module) as a short-cut; you're free to
        use your own classes.

        The underlying HTML parser is smart enough to "know" what
        elements terminate other elements (both explicitly and
        implicitly) so it "knows" where the end of the conditional or
        loop is.

> Wouldn't they break the "preview" ability?

        No: for loops, you just get one iteration; for conditionals, you
        get the result as if the condition were true.

        - Paul

Reply via email to