Here's what I do to make code mixed with HTML in PSP files manageable.  Your
mileage may vary...

What I do is indent "code" lines (the <%%> blocks) independently from the
HTML indentation.  Also, I only use a single line of code in a <% %> block,
keep it to a single line, and never have a code block and HTML on the same
line.  The exception is a multi-line chunk of code at the top of the file
for setup.

The <%= %> blocks are indented with the HTML, not the code, because they
represent output, not control flow.

For example:

<%
Multi line setup code
goes here
%>

<div>
    <table>
<%for i in range(10):%>
        <tr>
    <%for j in range(10):%>
            <td>
                <%=i%>,<%=j%>
            </td>
    <%end%>
        </tr>
<%end%>
    </table>
</div>

Notice how the "code" as defined by the <%%> blocks is indented
independently of the HTML, which is typically much more deeply nested than
the code.

This might look messy in plain text, but if you use a syntax highlighting
editor that makes the <%%> blocks stand out, then it's easy to see the code
structure and the HTML structure at the same time.

- Geoff

Winston Wolff wrote:
> Indentation is indeed awkward with PSP files.  I personally use
> Cheetah instead.
> 
> -ww
> 
> On Dec 1, 2004, at 4:08 PM, Douglas Soares de Andrade wrote:
> 
>> Hi !
>> 
>> I have a feature request to PSP.
>> 
>> See the example:
>> 
>> <%
>> res.write("This is a test and works.")
>> %>
>> 
>> <html>
>>  <tr>
>>   <td>
>>    <%
>>     res.write("This block will not work.")
>>    %>
>>   </td>
>>  </tr>
>> </html>
>> 
>> The code above dont work, to make it work i had to do:
>> 
>> <html>
>>  <tr>
>>   <td>
>> <%
>> res.write("This block will not work.")
>> %>
>>   </td>
>>  </tr>
>> </html>
>> 
>> This works... But, isn't there a way to make the nš 01 code work ?
>> This will be more legible and will make the output of the PSP script
>> follow the entire html identation.
>> 
>> Thanks !
>> 
>> --
>> Douglas Soares de Andrade - UnilesteMG
>> dsa em unilestemg.br - Linux User: #237615
>> http://douglasandrade.tk
>> 
>> 
>> 
>> -------------------------------------------------------
>> SF email is sponsored by - The IT Product Guide
>> Read honest & candid reviews on hundreds of IT Products from real
>> users. Discover which products truly live up to the hype. Start
>> reading now. http://productguide.itmanagersjournal.com/
>> _______________________________________________
>> Webware-discuss mailing list
>> [EMAIL PROTECTED]
>> https://lists.sourceforge.net/lists/listinfo/webware-discuss
> 
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real
> users. Discover which products truly live up to the hype. Start
> reading now. http://productguide.itmanagersjournal.com/
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to