Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Inline HTML

  • 21-04-2011 03:05PM
    #1
    Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭


    I'm in the middle of an horrific project where I'm redesigning a classic ASP website without touching the code, ie sticking to relocating and streamling the HTML only. The previous developer just mixed up ASP code and HTML as needed, so there's a lot of code like this
    <tr><td>
    <% if x=1 then %>
    hello</td></tr>
    <%
    else
      p = p+1
    end if%>
    <%=p%>
    </td></tr>
    
    It's pretty ugly and often impossible to find where an IF...END IF starts and ends, while making sure inline <TABLE>s etc keep their context aswell. I started indenting everything to try and get some order, but sometimes that looks worse:
    <tr>
      <td>
    <% 
    if x=1 then
    %>
        hello
      </td>
    </tr>
    <%
    else
      p = p+1
    end if%>
        <%=p%>
      </td>
    </tr>
    
    I just can't seem to get any sort of order and was wondering what other people do with code like this, where the HTML is intertwined.


Comments

  • Closed Accounts Posts: 9,698 ✭✭✭tricky D


    Would colour coding be of any help? NotePad++ treats the delimiters in yellow and code with some bold and some coloured.


  • Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


    We use VS which has some basic colour coding with ASP files, but to be honest, most of the problems occur when you pull out a load of code, but accidentally leave behind a </table> or a </div> and the whole page gets messed up. With indenting, it's easy to see where a section begins and ends. but then do you indent everything according to the HTML or to the ASP?


  • Registered Users, Registered Users 2 Posts: 12,026 ✭✭✭✭Giblet


    Yes there are templates and view engines which encourage this type of coding. Usually you make sure that it's only used for presentation logic though, I would't be setting variables, only reading.


  • Registered Users, Registered Users 2 Posts: 1,000 ✭✭✭MargeS


    This is how I used to write my classic ASP about 10 years ago.
    You're only option really is to use VS, go through it line by line & move your codebehind and use asp controls.


  • Registered Users, Registered Users 2 Posts: 15,079 ✭✭✭✭Malice


    In addition to the syntax highlighting that Tricky D mentioned, NotePad++ uses a plugin called HTML Tidy which might be some help. I use to reformat browser output from the View Source command occasionally. I can't remember if it supports script though. It might not.


  • Advertisement
  • Moderators, Society & Culture Moderators Posts: 9,688 Mod ✭✭✭✭stevenmu


    VS also has a "Format Document" option which can sometimes work wonders. Not sure how it stacks up against HTML Tidy but worth a go.


  • Registered Users, Registered Users 2 Posts: 15,079 ✭✭✭✭Malice


    stevenmu wrote: »
    VS also has a "Format Document" option which can sometimes work wonders. Not sure how it stacks up against HTML Tidy but worth a go.
    Good point. I find the Visual Studio IDE awkward to just create a simple file though. You hit Ctrl+N and then you've got to select the file you want. With NotePad++ Ctrl+N gets you a new blank document which you can start working with straight away.


  • Moderators, Society & Culture Moderators Posts: 9,688 Mod ✭✭✭✭stevenmu


    Good point, Visual Studio can be overkill if you're just making little change to lots of files, and notepad++ is nice for that.


Advertisement