Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Inline HTML

  • 21-04-2011 3: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,700 ✭✭✭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: 11,989 ✭✭✭✭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,002 ✭✭✭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,065 ✭✭✭✭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,689 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,065 ✭✭✭✭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,689 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