Support » Themes and Templates » Themes using Heredocs?

  • I’m a longtime programmer, but new to WP…


    print <<<MyQuery
    Has anyone done a theme where they use heredocs
    in their templates? What I would like to do is try
    to separate the information gathering from
    presentation as much as possible.

    (I basically want to avoid a lot of the
    <?php stuff ?>, and expand vars instead --
    the constant context-switching between HTML and
    PHP calls gets a bit cumbersome to read)

    My basic approach with loops would be (pseudo-code...)

    start SomeLoop {
    // gather vars...

    print <<< WhatEverWeNeed
    <!-- some section of HTML -->
    spit out $thisVar and $thatVar
    <!-- that"s it for this chunk -->
    WhatEverWeNeed;

    }

    MyQuery;

    I’m hoping someone has done this. If not, I’ll modify
    the default theme to this style and post it as an example.

  • The topic ‘Themes using Heredocs?’ is closed to new replies.