Support Forum

Recommended way to output HTML?

LH Lee H
Lee H
Member

Looking at the default template, all output is returned by functions. If we wanted to output HTML markup (or anything else)…  well I’m not sure the best approach.

Do we jump out of php and write the HTML directly? Or do we have to create oodles of functions to return the output? Or should we save the functions output to a variable like $out.= function_that_returns_stuff(); and return $out in the end like the old SP coding?

Your thoughts are appreciated.

7 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

personally I would mark it up in-line although that choice is a bit subjective I guess and dependent upon ones usual work practice. But in-line is fine,

MP Mr Papa
Mr Papa
Member

you will see we mix jumping out of php for straight html and echo’ing html…  really just a preference or amount of html needed… I am getting to where I like to jump out of php and just dump the html…  easier to handle indentations…

LH Lee H
Lee H
Member

We can echo? I did see echoing in some of the functions and assumed it was a option to output to the main blog in a widget or something.

YS Yellow Swordfish
Yellow Swordfish
Member

Yes echo or raw html. No more $out and return. ALL template functions echo unless you specify otherwise in the arguments and use ‘get’.

LH Lee H
Lee H
Member

LOL! Had I realized that… I wouldn’t of asked this question. So this really IS like a WP theme 🙂