So I realized today, after making a table building class, that it looks ugly when viewing the source. It makes it harder to find specific HTML elements, unless using Firebug or something similar.
I have thought about going in and adding new line characters and tabs so that not all my dynamic HTML is a single line but realizing this makes my PHP code look uglier.
So it seems a flip of either ugly PHP or uglier HTML. It probably wouldn't be a huge deal to format the HTML or even just add new line's every now and then, but I still don't like what it adds to the PHP.
What do you guys prefer doing? Better looking PHP, HTML, or a mix of the two?
Edit: I kept saying PHP. Although this does apply to ASP, Ruby, and other Web languages.
5 replies to this topic
#1
Posted 06 December 2010 - 11:30 AM
|
|
|
#2
Posted 06 December 2010 - 02:38 PM
What PHP code you have in templates that you can't format nicely? Generally there should be just one-liners:
I format both HTML and PHP using 2 space as indentation, but I don't use much PHP in templates (generally just conditions and loops).
You can also take a look at Twig - definitely best template engine for PHP.
<ul>
<?php foreach (get_items() as $item): ?>
<li><a href="<?= url_for('item', $item) ?>"
target="_blank"><?= $item ?></a></li>
<?php endforeach; ?>
</ul>
I format both HTML and PHP using 2 space as indentation, but I don't use much PHP in templates (generally just conditions and loops).
You can also take a look at Twig - definitely best template engine for PHP.
#3
Posted 06 December 2010 - 05:18 PM
Generally, my server side language is more important to me. Ideally, you want to minimize the amount of white-space sent to the browser, anyway. It can make a big difference in speed of the site.
#4
Posted 07 December 2010 - 02:57 AM
I would choose better look php (or any source code that matters) for better maintenance (debugging, tracing, improving). As for the html, there is a lot of good tools out there. Beside that since it's actually xml, any xml formatting utility will help. For occasional user, every web browsers provide search feature, right?
#5
Posted 10 December 2010 - 08:00 PM
#6
Posted 12 December 2010 - 08:15 PM
If you can call webservices in a asynchronous manner, send the html to the service let it format the code and return you the result.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account



Back to top









