ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Nicely indented HTML

March 15, 2008 1:39pm

Subscribe [12]
  • #16 / Mar 16, 2008 2:19pm

    Jared Farrish

    575 posts

    brandon.kelly: True.  😏

    RoelVG: In your case, you need to find a hook into the EE display to transform the code server-side, hence my edit and link to the PHP docs page. I would think this would be a relatively simple extension to write, actually, although support might be question mark, unless the developer is familiar with tidy transformations. Unexpected behavior… 😊

    If you were caching and the cached page wrote actual code that was transformed to file, that is the best case, in any case, which would seem to be the behavior I would *think* you would see in EE.

    For someone who cares not a whit to transform the page, though, it is just not necessary to do, and should by default be disabled if it were part of the EE codebase. I think it would be nice edition for the debug environment, really.

    Especially for professional developers…  :cheese:

    😊

  • #17 / May 22, 2008 1:54pm

    Hi,

    I was wondering if there is a solution to that problem (indented HTML)? I’m testing EE on my web development server but like Summer Student, it’s a bit messy when I checked to the XHTML rendered code even if I indent my code correctly in the source.

    Thanks.

  • #18 / Jun 29, 2008 4:48am

    lebisol

    2234 posts

    Subscribing…

  • #19 / Jun 29, 2008 4:56am

    Danny T.

    426 posts

    +1

    Always was curious how to get clean outputted HTML with proper whitespacing.. Haven’t been able to do it quite yet. 😊

  • #20 / Jun 30, 2008 12:08pm

    Joe Michaud

    154 posts

    Yea, this is one of those “would be nice if…” things.  Not a high priority for me but interesting enough to subscribe to the thread.  =)

  • #21 / Jun 30, 2008 3:41pm

    hothousegraphix

    851 posts

    This was one of the first things I noticed when I began using EE a little over one year ago.

    This issue is talked about in a number of threads. One such is located here.

    I’ve found that to achieve nice cleanly rendered mark-up you have to make the decision to approach writing your templates differently. I would assume, if you’re like me, I started by breaking down examples in the docs, from the forums, and any place I could find helpful information.

    Most of these examples follow a specific formatting convention that is very easy to follow.
    However, it also can lead to extra white space written to your rendered page.

    Take for instance an opening and closing weblog tag, like

    {exp:weblog:entries  weblog="news"  orderby="date"  limit="5" }
    {news_entry}
    {/exp:weblog:entries}

    When these tags are devoted to their own line in your template, the corresponding area in your rendered page will be an empty line.

    Granted, a really basic example, but this is where I started to lean how the system was generating it’s output.

    It’s conditionals that are the big culprit. Something like this, which has a bunch of white space written into it:

    <div id="main_col">
        <div>
            {exp:weblog:entries weblog="{my_weblog}" sort="desc" limit="3"}
            {if segment_2 == my_value}
            <h1>{location_1}</h1>
            {if:else}
            <h1>{location_2}</h1>
            {/if}
            {/exp:weblog:entries}
        </div>
    </div>

    I would write like this now:

    <div id="main_col">
        <div>
            {exp:weblog:entries weblog="{my_weblog}" sort="desc" limit="3"}{if segment_2 == my_value}<h1>{location_1}</h1>
            {if:else}<h1>{location_2}</h1>
            {/if}<h2>title</h2>
    <p>        {section_image}<br />
            {section_text}<br />
        {/exp:weblog:entries}</div><br />
    </div>

    If you’re ok with your template being formatted differently, you can pretty much eliminate all the issues you’re currently observing.

  • #22 / Jun 30, 2008 4:03pm

    lebisol

    2234 posts

    Thanks hothousegraphix!
    Call it obsessive compulsive but it matters…nice trick!
    Sadly, when templates are edited of line now it looks like garbage to our ‘human rendering engine’...
    I suppose we will have to keep 2 versions of templates “nicely rendered by EE” and “easily rendered by developer”.
    So much time & energy wasted into whitespace.  :down:

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases