custom php template engine: am i finally right track?
since i keep arrangement adult late responding questions tagged php where i indeed know answer i figured i'd try seeking doubt myself.
i've operative finish rewrites tradition template engine php enlarged times i guess i'd ask opinions.
in short, many vicious biased i have implemented far:
- any http ask routed handler.php
- based requested url controller instantiated slight controller called.
- the controller slight contingency relapse an
iviewcongruous category instance (iviewdefinesrender()method)- the template engine does xpath each namespace ends 'serverside'
sprintf('//%s:*[@runat="server"]', $namespaceprefix ) - for each found tag, looks adult php category identified
$tag.localnameinstantiates attaches uncanny template. - once attached, uncanny template node fed 'servertag' initialize properly
- the entirely finish iview congruous instance indifferent surrogate non-static controller method.
- the template engine does xpath each namespace ends 'serverside'
- the controller asks pushes information denote category perspective does nifty xpath dom replacement.
- the controller advantage totally filled perspective
main()the handler, renders it.
i am basing template xml. rudimentary template now looks like:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:red="http://www.theredhead.nl/serverside">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>title filed perspective depending controller</title>
<link rel="stylesheet" type="text/css" href="/stylesheet/get/main/" />
</head>
<body>
<!-- whole physique competence reset perspective controlling it, controlling xpath dom functions -->
<!-- wholly pageheader pagefooter put behind after clearing physique -->
<div id="pageheader">
<img src="/image/get/theredhead_dot_nl.png" alt="site logo" />
</div>
<h1>www.theredhead.nl :: exam template</h1>
<p>
lorum ipsum dolar lay amet. blah blah blah yackadee schmackadee.
</p>
<div id="pagefooter">
built by
<br />
<red:userprofilelink runat="server" username="kris" />
</div>
</body>
</html>
at current, outputs (including damaged indentation):
<!doctype html open "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:red="http://www.theredhead.nl/serverside">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>welcome site</title>
<link rel="stylesheet" type="text/css" href="/stylesheet/get/main/"/>
<link rel="stylesheet" type="text/css" href="/stylesheet/get/custom/"/>
<link rel="stylesheet" type="text/css" href="/stylesheet/get/profile/"/>
</head>
<body>
<!-- whole physique competence reset perspective controlling it, controlling xpath dom functions -->
<!-- wholly pageheader pagefooter put behind after clearing physique -->
<div id="pageheader">
<img src="/image/get/theredhead_dot_nl.png" alt="site logo"/>
</div>
<h1>www.theredhead.nl :: modelviewcontroller</h1>
<p>
lorum ipsum dolar lay amet. blah blah blah yackadee schmackadee.
</p>
<div id="pagefooter">
built by
<br/>
<div><div xmlns:profile="http://www.theredhead.nl/profile" class="profilebadge" style="font-size : .8em;">
<a style="text-decoration : none; border: none;" href="/profile/view/kris">
<img style="float : left;" src="http://www.gravatar.com/avatar/5beeab66d6fe021cbd4daa041330cc86?d=identicon&s=32&r=pg" alt="gravatar"/>
 kris
</a>
<br/>
<small>
 rep: 1
</small>
</div></div>
</div>
</body>
</html>
- i've wholly proposal tip iceberg here yes, i stripping new xmlns attributes cost once i'm happy functionality
- there now only over 200 classes mvc core frameworks
- i am wakeful there existent solutions identical things, nonetheless i wish build own.
so large doubt is: do have any quarrel must-have functionality?
p.s. anyone prying finish source-code, greatfully leave comment, i providing site i strech reasonable developer usability levels.
Comments
Post a Comment