Pet peeve about proper indenting of HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

I'm format specific myself.

I find when coding, if you close every tag (like you're supposed to) your PHP and HTML can be all nicely formatted together, with tabs opening and closing where they should. Start at the left, end at the left. Although I think I read somewhere that I'm supposed to use four spaces instead of tabs. :( Ah well.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Hmm... then I'm doing something incorrectly formatting wise. Can I see a piece of template code of yours that includes a conditional on an entire block element?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Roja wrote:You have a habit of making assumptions about the habits of others, and it would help to consider that lately, each time you do, I've had to speak up to tell you that I'm the opposite. :)
Roja has given me the what for! :)
Roja wrote:Personally, I try to keep my html well formatted so that I can easily spot where the indenting is incorrect.
A little (Freudian) slip here, I think you meant, "where the syntax is incorrect." 8O
Roja wrote:It has helped me solve more html problems than using the validator
I agree to an extent. For me, reasonable vertical formatting of HTML gives me enough information to help spot problems -- I just don't find that indenting adds much for me given the effort to maintain the indenting. Also since I use hierarchical templates, the blocks get inserted whereever and maintaining correct indent level between disjoint HTML is simply too much work (and impossible when a block can be inserted in multiple places that have different levels of indenting).
(#10850)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Ambush Commander wrote:The other, function echo stuff, is a sad attempt at a Transform View without XSLT.

Code: Select all

function runReporter(&$reporter) {
        $reporter->paintHeader('Edit Wikipedia\'s Status');
        $reporter->paintEditFormStart();
            $reporter->paintImportantServicesField($this->important_services);
            $reporter->paintLesserServicesField($this->lesser_services);
            $reporter->paintSymptomGroupsField($this->symptomgroups);
            $reporter->paintCommentField($this->username);
            $reporter->paintSubmitButton();
        $reporter->paintEditFormEnd();
        $reporter->paintFooter();
    }
Indenting code to match the indenting level if it's output!?!?
Last edited by Christopher on Fri Apr 14, 2006 6:38 pm, edited 2 times in total.
(#10850)
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

:lol: Yup. A lot easier to read, in my opinion, than a solid block of paints.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I would do vertical separation instead:

Code: Select all

function runReporter(&$reporter) {
        $reporter->paintHeader('Edit Wikipedia\'s Status');
        $reporter->paintEditFormStart();

        $reporter->paintImportantServicesField($this->important_services);
        $reporter->paintLesserServicesField($this->lesser_services);
        $reporter->paintSymptomGroupsField($this->symptomgroups);
        $reporter->paintCommentField($this->username);
        $reporter->paintSubmitButton();

        $reporter->paintEditFormEnd();
        $reporter->paintFooter();
    }
(#10850)
Post Reply