Skip to main content
Topic: Output whitespace (Read 2886 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Output whitespace

A long time ago I wrote the coding standards/guidelines for SMF. I was trying to make things better. Today, I think those standards are horrible. One thing that annoys the hell out of me is that the whitespace should be formatted for the output. Big deal back in YaBBSE days when there weren't any good HTML tidy applications. Today, not so much as every IDE and editor can do this including dozens of online tools.

So, I propose that the output be formatted for where it is being outputted from. If it is inside of a function it should be formatted so you can read it inside of the function. I want you to read that again - it should make sense for where it is being outputted from. That doesn't mean you can't put a newline to make it better in the output. It just shouldn't need to be that way and you should try to make it better for the backend developer. The front-end developer will use a tool to tidy the HTML and format it the way they want.

Re: Output whitespace

Reply #1

Yep, agree.
Mostly because, if we are going down the way of code re-use, different functions may be called at different levels of indentation, so in few places it's already basically useless to have it done that way.

If I got what you mean. :P
Bugs creator.
Features destroyer.
Template killer.

Re: Output whitespace

Reply #2

 I always thought SMF had a pretty good indenting routine, having indenting separately the PHP and the HTML. Not sure who was the starter of that, I remember Compuart + Grudge was quite fond of correcting things lol.

That said..having functions being re-used means sometimes the indenting is off in those. But IMHO it will harder to read if the indenting start from the same point everywhere. 

Re: Output whitespace

Reply #3

In SMF, indenting is based on how it is supposed to look in the output which leads to crazy indenting in the source files. Better for the developers if it looks right in the source files and then you can use HTML Tidy or similar to make it look good in the output.

Re: Output whitespace

Reply #4

But should HTML even be in Source files? ;) In my opinion: absolutely not.

Re: Output whitespace

Reply #5

Template files. Still have control structures.

Re: Output whitespace

Reply #6

Yea, I'd like to see us drop that as well ...

It was all good intentions (and looks really nice), but it hampers reuse should you require that the indentation in the output stream be proper for the entire page.

TBH what we have is mostly wrong everywhere anyway.  It was fixed in a few main spots but then you realize all you have to do is add or remove one div in the top wrapper and you just caused yourself to edit every function in every template, nuts!  So I'm good with proper indentation in the functions but trying to indent that for the total page structure is futile IMO.

Re: Output whitespace

Reply #7

It can always start with 1 indent for the first tag of the function, and then according to the nesting level.
Bugs creator.
Features destroyer.
Template killer.

Re: Output whitespace

Reply #8

Well, I don't always get it correct either, especially when I use several smaller functions..but I find the theme/template files alot easier to read if the main flow is indented correctly. Theres been quite a few mistakes that I could break down just by following the indent. I don't feel I should just ditch the whole concept of indenting properly because I get it wrong sometimes. Once its there, its done, so getting it right is a goal in it self, for me.

There are of course functions that are called several times, and they will not ever be correct, so they aren't lol. I can still have the main flow though.

But ultimately its a matter of choice.

Re: Output whitespace

Reply #9

Are you saying indent correctly for the template or indent correctly for the output? I just use tidy plugins in my IDE but now that I think about it, I think I'll look for one for Chrome too.

Re: Output whitespace

Reply #10

Of course for the template..the output only reflects it.