[Define New Theme] 17. Completely remove all generated HTML from the core.

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

[Define New Theme] 17. Completely remove all generated HTML from the core.

Post by hanakin »

*Note This is part 1 of a series found here

This should really be a no brainer but the the backend should not be serving any HTML what so ever, neither should the JS for that matter. Their are better ways for handling these situations. Furthermore there are a number of places where its not even being done for any purpose what so ever case in point

There are several places where an img is being returned which may sound like not that big a deal, but when working to try and make style changes this holds up production as we have to translate all the template variables that use a random function to build just this sort of thing which is assigning and slows down progress while at the same time making it difficult for a novice to change it as well.

There is absolutely no situation when HTML should be returned via PHP or JS and all these occurrences need to be deprecated/removed

Thoughts & suggestions
Donations welcome via Paypal Image

User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: [Define New Theme] 17. Completely remove all generated HTML from the core.

Post by MattF »

Sometimes it is unavoidable. Like when returning a string from a language variable, but you need to use a strong or em tag on a word inside the string...or add a line break to a long string.

Same goes for JS. One of the main uses of JS is to manipulate the DOM, and often times that means generating some new DOM elements. And in some cases it does make more sense to do that in the JS.

I agree it should be weeded out as much as possible, but it's not going to be 100% removed from PHP and JS. When it is coming from PHP or JS, it should be as generic as possible, like just the simple tags I mentioned above.
Has an irascible disposition.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [Define New Theme] 17. Completely remove all generated HTML from the core.

Post by callumacrae »

VSE wrote:Same goes for JS. One of the main uses of JS is to manipulate the DOM, and often times that means generating some new DOM elements. And in some cases it does make more sense to do that in the JS.
Wrong! Just have a hidden element sent in the original HTML and clone it. Much cleaner.
Made by developers, for developers!
My blog

User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

Re: [Define New Theme] 17. Completely remove all generated HTML from the core.

Post by nickvergessen »

Well this is really nothing we need to discuss.
We try to do that and often already moved the html into the template and created a loop in the php code.
Member of the Development-TeamNo Support via PM

User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

Re: [Define New Theme] 17. Completely remove all generated HTML from the core.

Post by hanakin »

VSE wrote:Sometimes it is unavoidable. Like when returning a string from a language variable, but you need to use a strong or em tag on a word inside the string...or add a line break to a long string.

Same goes for JS. One of the main uses of JS is to manipulate the DOM, and often times that means generating some new DOM elements. And in some cases it does make more sense to do that in the JS.

I agree it should be weeded out as much as possible, but it's not going to be 100% removed from PHP and JS. When it is coming from PHP or JS, it should be as generic as possible, like just the simple tags I mentioned above.
Not true em and strong should never be included other than in the template. I somewhat agree on layout <br> and <p> possibly, but even these can be worked around using some sort of template macro. Definitely not images and links as these require very hacky workarounds for styling.
Donations welcome via Paypal Image

Senky
Extension Customisations
Extension Customisations
Posts: 315
Joined: Thu Jul 16, 2009 4:41 pm

Re: [Define New Theme] 17. Completely remove all generated HTML from the core.

Post by Senky »

hanakin wrote:Not true em and strong should never be included other than in the template...
Imagine such language entry:
text text <em>text</em> text text <strong>text</strong> text <strong>text</strong> text
Would you divide it to 3 language variables just to keep HTML out of language files?

I would say that almost all <br>s can be avoided using margin and <p>s are such remarkable in meaning of semantics, that if required to use in php, we should think of better code structure.

User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

Re: [Define New Theme] 17. Completely remove all generated HTML from the core.

Post by hanakin »

in what situation would that be required? and yes I would break it up as if you are making something bold or italic its usually its own content anyway. Plus its better to use bbcode and run something like blocks of text through the bbcode parser which we do have control over via bbcode.html
Donations welcome via Paypal Image

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [Define New Theme] 17. Completely remove all generated HTML from the core.

Post by callumacrae »

hanakin wrote:in what situation would that be required? and yes I would break it up as if you are making something bold or italic its usually its own content anyway. Plus its better to use bbcode and run something like blocks of text through the bbcode parser which we do have control over via bbcode.html
"Page <strong>%d</strong> of <strong>%d</strong>" is an obvious example. You can't split it up, because it might not be in the same order in different languages.
Made by developers, for developers!
My blog

User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

Re: [Define New Theme] 17. Completely remove all generated HTML from the core.

Post by hanakin »

callumacrae wrote:
hanakin wrote:in what situation would that be required? and yes I would break it up as if you are making something bold or italic its usually its own content anyway. Plus its better to use bbcode and run something like blocks of text through the bbcode parser which we do have control over via bbcode.html
"Page <strong>%d</strong> of <strong>%d</strong>" is an obvious example. You can't split it up, because it might not be in the same order in different languages.
its still better to use some sort of abstraction layer to accomplish this rather than harcoding the tags to allow for complete customization of the rendered html via templates.

run the template variable through filter for some sort of custom bbcode perhaps. This way if the theme author wishes to swap out the strong tag for an em tag or a simple span, maybe apply a unique class to this situation it can be easily done for all cases from within the bbcode.html file.
Donations welcome via Paypal Image

Dan Kehn
Registered User
Posts: 1
Joined: Wed Nov 07, 2007 3:17 pm

Re: [Define New Theme] 17. Completely remove all generated HTML from the core.

Post by Dan Kehn »

callumacrae wrote:"Page <strong>%d</strong> of <strong>%d</strong>" is an obvious example. You can't split it up, because it might not be in the same order in different languages.
You can use sprintf and argument position indicators. See "argument swapping" here: http://php.net/manual/en/function.sprintf.php. For example:

Code: Select all

<?php
$format = 'The %2$s contains %1$d monkeys';
echo sprintf($format, $num, $location);
?>
The translator can then swap the order of presentation as the language requires (e.g, in French, the adjective usually appears after the noun).

Post Reply