About Template
About Template
Fegg is equipped with its own template engine where you can separate application code (PHP Code) and display (HTML/CSS). Fegg uses the {{}} tag for your application code in the template file. It runs a method that compile templates from Controller class.
Template files are save under the code/template/ directory with name format of template_name.tpl.
Display methods
Display methods call the template file from Controller class.
Below are the display methods in Fegg but it is recommended to use only the displayPage method to avoid Clickjacking attacks.
📄️ Application::displayTemplate
Display compiled template
📄️ Application::fetchTemplate
Return compiled template into a string
📄️ Application::fetchPage
Return compiled template with declared controller and template variables into a string
📄️ Application::displayPage
Display compiled template with automatically variables and taking measures for Clickjacking
Template helper methods
Template helper methods are used for passing special variable to the template.
📄️ Application::setSiteinfo
Set website information (ex. title, description, keywords)
📄️ Application::setHidden
Set hidden data
📄️ Application::setHtmlHeader
Set HTML Header
Template rules
There are several operating notation for template file.
📄️ Variable
The use of variables in the template
📄️ If
if, else, else if
📄️ Loop
loop, foreach
📄️ Include
include, include head, head, include foot, foot
📄️ Transclude
transclude, section
📄️ Checked/Selected
checked, selected, options, hidden
📄️ Options
Make option tags
📄️ Hidden
Display hidden tag
📄️ Code
call, code
Modifiers
You can modify the returned values of your variable in your application code in template using modifiers.
📄️ Modifiers
You can modify the returned values of your variable in your application code in template using modifiers.