Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

Template guidelines and recommendations

9:22 pm on Aug 26, 2013 (gmt 0)

Full Member

5+ Year Member Top Contributors Of The Month

joined:Sept 30, 2009
votes: 0

Are there guidelines or recommendations I can solicit for two questions that arise as I develop a framework utilizing templates to customize a site's look:
  • What should the template file extension be?
  • How should I format the placeholder text?
I doubt there are any performance benefits of one method over another, and since this framework is purpose-built from scratch I can practically choose anything, but don't want to make the decision blind.

In the framework, a user specifies the name of one of several templates, or can include their own that they've downloaded, developed, or derived. As needed, the framework references one of several static files from inside the template's folder, substitutes placeholder text inside the file, and saves customized files inside a cache for future reuse.

Currently I'm using the .txt file extension for the template files to make them less intimidating if a user wants to open one up, explore, and maybe save changes as a new template. I'm also using the .txt file extension and blocking browsers from directly accessing the template folders out of security concerns. I don't want, for example, for templates to be executable scripts when there is no need, or for a writer to develop and distribute templates that maliciously output sensitive setting in a html comment on the homepage, delete the database if a file is directly accessed, or create other backdoors.

For placeholder text I'm using {{SettingsName}} though I'm interested in what else has been used, maybe %SettinsgName% or something else? For further security, the placeholders are automatically generated from all "safe" user and database settings that were clearly marked as publicly available.

Basic concept of the template script:
$placeholders = array('{{PageName}}'=>'Example', '{{Domain}}'=>'example.com', '{{BackgroundColor}}'=>'#abcdef'); 
$html = strtr('BasicTemplate.txt'), $placeholders);

Example of BasicTemplate.txt:
<title>{{ProductName}} - {{SiteName}}</title>