*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
[Define New Theme] 17. Completely remove all generated HTML from the core.
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.
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.
Re: [Define New Theme] 17. Completely remove all generated HTML from the core.
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.
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.
- 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.
Wrong! Just have a hidden element sent in the original HTML and clone it. Much cleaner.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.
- 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.
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.
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-Team — No Support via PM
Re: [Define New Theme] 17. Completely remove all generated HTML from the core.
Not true em and strong should never be included other than in the template. I somewhat agree on layoutVSE 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.
<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.Re: [Define New Theme] 17. Completely remove all generated HTML from the core.
Imagine such language entry:hanakin wrote:Not true em and strong should never be included other than in the template...
Would you divide it to 3 language variables just to keep HTML out of language files?text text <em>text</em> text text <strong>text</strong> text <strong>text</strong> text
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.
Re: [Define New Theme] 17. Completely remove all generated HTML from the core.
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
- 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.
"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.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
Re: [Define New Theme] 17. Completely remove all generated HTML from the core.
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.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.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
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.
Re: [Define New Theme] 17. Completely remove all generated HTML from the core.
You can use sprintf and argument position indicators. See "argument swapping" here: http://php.net/manual/en/function.sprintf.php. For example: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.
Code: Select all
<?php
$format = 'The %2$s contains %1$d monkeys';
echo sprintf($format, $num, $location);
?>