Friday, 27 October 2017

ROLL YOUR OWN TEMPLATING SYSTEM IN PHP




Why Do I Need to Build a Templating System?

Step 1 Plan the System

  • What We Need to Build
  •  How the Templating System Works

Step 2 Outline the Class
  • Create the Folder Structure
  •   Create the Main Files

Step 3 Define a "Template"
  •  What Would the HTML Look Like?
  •  Use the Variable Data to Choose Template Tags

Step 4 Load the Entries
  •    Tie the Entries to the Templating System

Step 5 Load the Template File
  •   Make Sure the File Exists

Step 6 Parse the Template
  •  But First, a Word About Regular Expressions
  • Get Ready for Testing
  • Remove Comments from the Template File
  •  Separate the Header, Footer, and Loop for Processing
  •  Isolate the Main Entry Loop
  •  Isolate the Header
  • Isolate the Footer 
  •  Identify Template Tags with Regular Expressions

Step 7 Get Ready for Template Tag Replacement: Currying
  •  Wait. What Did You Just Say?
  • Write the Currying Method
  • How Does Currying Apply to the Templating System?

Step 8 Replace Template Tags with Matching Entry Data
  • Write the Tag Replacing Method
  • Modify the Template Parsing Method to Replace Template Tags
  •  Replace Template Tags in the Header and Footer of the Template

Step 9 Use Real Entries
  •  Create a Template
  •  Load Real Entries and Use the New Template

 For more details, refer this url :
https://code.tutsplus.com/tutorials/roll-your-own-templating-system-in-php--net-16596

write by :
Che Wahida (programmer team) 

0 comments:

Post a Comment