Skip to content

daffodil/idiots-guide-2-templating

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

idiots-guide-2-templating

First lets rwwind to the start of the internet in html

The sun rises above the dawn, the shadow silently vanishing behind the developer's desk as a few stokes and hits on keys echoed around the room, code was being tested, printers were silent, a birth on the internet and html, and some hacker was concerned about having to make a lot of pages,and created the first templates, which could have looked like this....

<!-- And mad idea for a template {me} -->
<html>\n
<head>\n
\t<title>@@@TITLE### | @@@SITE_TITLE###</title>\n
</head>\n
<body>\n
\t<h1>@@@TITLE###</h1>\n
\t<hr>\n
\t<h2>@@@SUMMARY###</h2>\n
\t<h3>@@@PERSON###</h3>\n
\t@@@CONTENT###
\t<hr>
\t@@@FOOTER###
</body>\n
</html>
// my variables for party..
$title = "Its party  time..."
$site_title = "Univerity Hack Dept"
$summary = "Hey guys and gals, if u see\t this\n then ping me on \t192\168\5\7 for some HTML"
$content = "Party time!!!!!!!!! room 14466545745|unix """
$person = "NULL"
$footer = "RSVP = [email protected]"

// read template file
$TemplateFile = open("template.htm")
$tpl = $TemplateFile.readAll()
close($TemplateFile)

// get invite list
$EmailsFile = open("template.htm")
$emails_list = $EmailsFile.readAll()
close($EmailsFile)

$guest_list = split($emails_list, "\n")


for( $guest_list as $guest){
	// replace tempalte vars with persons
	$tpl = replace($tpl, "@@@SITE_TITLE###", $site_title)
	$tpl = replace($tpl, "@@@TITLE###", $title)
	$tpl = replace($tpl, "@@@SUMMARY###", $summary)
	$tpl = replace($tpl, "t@@@FOOTER###", $footer)
	sendmail("[email protected]", $guest, $tpl)
}
// :-)

So depending where your coming from, the idea here is to guide thought the concepts and how their implemented..

First Template

-----------------------------------------------------
Site Title
-----------------------------------------------------
Title
========
Contents
blah,
blah, blah blah


----------------------------
footer

Template Syntax.

For this exersize... we want a standard tempalte that does a few clever things..

current date in your locale, and UTC dates

Standard header and footer with terms..

An active navigation system that higlights a page in nav

About

An Newbie guide to html templating

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published