Re: Tidy HTML source?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 30 November 2006 18:51, Paul Novitski wrote:
> At 11/30/2006 01:52 AM, Satyam wrote:
> >>>>And, stepping back, you're perpetuating the embedding of markup
> >>>>with logic so that it will still take a PHP programmer to modify
> >>>>the markup of one of your pages.  Do you not see the advantage in
> >>>>separating the two layers?
> >>>
> >>>Yes, I do, and I would recommend using templates or similar tools
> >>>to provide for separation of code and markup, but sometimes there
> >>>are reasons not to do so, for example, web services.
> >>
> >>Please explain why you think web services promote mixing markup with
> >> logic.
> >
> >I didn't say it promotes but it does not require. In web services
> >there is usually no presentation layer, there is no end user to see
> >anything at all, then there is no need for a graphics designer
> >separate from the application programmer. The application consuming
> >that service might have to display the data, but the service does not.
>
> To reach clarity on this point, let's leave presentation out of
> it.  I was referring to the separation of presentation from markup
> merely to suggest an analagous separation that many of us have
> accepted as being helpful to design, development, and
> maintenance.  What I'm really curious about in this discussion is the
> separation of markup from logic.
>
> With respect to separating code and markup, you said "sometimes there
> are reasons not to do so, for example, web services."  What are some
> of those reasons?
>
> Cheers,
> Paul

What about performance ? What about compexity ?

Those SO nice seperated template system produces lots of mini TPL files. You 
have to include them...  You have to parse them.

Also you have to track and manage them. 

And I'm not sure those template system gives you freedom. Because you cannot 
change your site design with this tpl files. If you change them too much you 
have to change your php code.

Plus if I remember correctly there was thing named CSS to change your site 
looks.

After 10 years of html coding by hand and 6 years of php coding and from my 
uber biased point of view. That template engine thing was flawed.

Look open source cms projects, check open sourced forums etc etc. Then tell me 
what is effective use of tpl files for message posting form or blog showing 
pages. Or someting like that...

Oh yes I know lots of sites are using them, then what ? People still use 
windows... Is that makes Windows best operating system ?

Maybe it useful. when your Designer does not know php and or your programmer 
does not know html/css.

And my point of view. Using <html tag <?php echo value ?> > <?php echo 
value ?></htmltag> days are over... 

These days we have to deal lots of other programming things. handle heavy 
loads, do lots of security things etc etc...

Of course you could do nice things for your liddle home page via old style 
php.

I believe Satyam's idea was best. I try to implement his idea with my way

function getTab($intTab=1)
{
	$strTab = NULL;
	for($i=0;$i<$intTab;$i++)
	{
		$strTab.= "\t";
	}
	return $strTab;
}

function html($arrOpt)
{
	$arrKeys = array_keys($arrOpt['attlist']);
	$intSize = sizeof($arrOpt['attlist']);
	$strAttlist = null;
	for($a=0;$a<$intSize;$a++)
	{
		$strAttlist.= " ".$arrKeys[$a]."='".$arrOpt['attlist'][$arrKeys[$a]]."'";
	}
	return getTab($arrOpt['tab'])."<".$arrOpt['tag'].@$strAttlist.
$arrOpt['end'].">\n";
}

MY RECENT METHOD
$strReturn.=
html(array('tag'=>'table','attlist'=>array('id'=>'uberTable','border'=>'0','cellpadding'=>'0','cellspacing'=>'1','width'=>'100%','class'=>'cUberTable'),'tab'=>4,'end'=>NULL))
.html(array('tag'=>'tr','attlist'=>array('class'=>'cUberTableTR'),'tab'=>5,'end'=>NULL))
.html(array('tag'=>'td','attlist'=>array('align'=>'center','valign'=>'top','class'=>'cUberTableTD'),'tab'=>6,'end'=>NULL))
."Test Message\n"
.html(array('tag'=>'/td','tab'=>6,'end'=>NULL))
.html(array('tag'=>'/tr','tab'=>5,'end'=>NULL))
.html(array('tag'=>'/table','tab'=>4,'end'=>NULL));


TPL METHOD
uber.tpl
				<table id='uberTable' border='0' cellpadding='0' cellspacing='1' 
width='100%' class='cUberTable'>
					<tr class='cUberTableTR'>
						<td align='center' valign='top' class='cUberTableTD'>
|MESSAGE|
						</td>
					</tr>
				</table>

Code

$TPL = new TplClass;
$TPL-> SetTplPath('tpl/meta.tpl',__FILE__,__LINE__);
$TPL-> ReadTpl();
$TPL -> Assign('|MESSAGE| ,'Test Message',__FILE__, __LINE__);
$TPL -> Showtpl();

SATYAM WAY 

<table  &border '0' &colspan '0' &cellpadding '1' &width '100%' 
class 'uberTable';
{
	<tr 
	{
		<td &align 'right' &valign 'top';
		{ 
			?  "Test message "; 
		}
	}
}
(and his curret implementation need pre-compiler)

Those Codes produces html like this

				<table id='uberTable' border='0' cellpadding='0' cellspacing='1' 
width='100%' class='cUberTable'>
					<tr class='cUberTableTR'>
						<td align='center' valign='top' class='cUberTableTD'>
Test Message
						</td>
					</tr>
				</table>

I wish to access his works under php via pear or someting like that. And I 
believe later or sooner we see this kind of aproach in other languages. 
I hope php was first one.

Hope Larsmus see this...

Regards

Sancar

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux