Usage: static object: Class::method() - This class provides only STATIC methods
class Methods
public staticfunctionanalyze_debug_template (
string$mtemplate
) {} :: STRING
@return: {STRING} The analyze info HTML+JS
@param: {STRING} $mtemplate: The Marker-TPL string
Analyze a Marker Template String (NO Sub-Templates are loaded)
This is intended for DEVELOPMENT / DEBUG ONLY (never use this in production environments !)
@return: {STRING} The parsed template
@param: {STRING} $ptemplate: The Placeholder-TPL string (partial text/html + placeholders) ; Ex: '<span>[:::PLACEHOLDER:::], ...</span>'
@param: {ARRAY} $y_arr_vars: The associative array with the template variables ; mapping the array keys to template placeholders is case insensitive ; Ex: [ 'PLACEHOLDER1' => 'Value1', 'placeholder2' => 'Value2', ..., 'PlaceholderN' => 100 ]
@param: {ENUM} $y_ignore_if_empty: 'yes' will ignore if Placeholder-TPL is empty ; 'no' will add a warning (default)
Render Placeholder Template (String Template ; no marker syntax is parsed ; only placeholders are strict replaced
This method adds a new feature to the Marker-TPL Templating system to allow add post-render variable areas to an already rendered Marker-TPL ; for example, a rendered Marker-TPL can be exported to cache but some areas perhaps need to be changed later so those areas can be replaced later by using placeholders
@return: {STRING} The parsed and rendered template
@param: {STRING} $y_file_path: The relative path to the file Marker-TPL (partial text/html + markers + *sub-templates*) ; if sub-templates are used, they will use the base path from this (main template) file ; Ex: views/my-template.inc.htm ; (partial text/html + markers) ; Ex (file content): '<span>[###MARKER1###]<br>[###MARKER2###], ...</span>'
@param: {ARRAY} $y_arr_vars: The associative array with the template variables ; mapping the array keys to template markers is case insensitive ; Ex: [ 'MARKER1' => 'Value1', 'marker2' => 'Value2', ..., 'MarkerN' => 100 ]
@param: {ENUM} $y_use_caching: 'yes' will cache the template (incl. sub-templates if any) into memory to avoid re-read them from file system (to be used if a template is used more than once per execution) ; 'no' means no caching is used (default)
Render Marker File Template (incl. Sub-Templates from Files if any)
Sample code: PHP <?php// [###MARKER###] :: marker with no escapes// [###MARKER|{escapes}] :: marker with escapes (one or many of): |bool |int |dec[1-4]{1} |num |htmid |jsvar |slug |substr[0-9]{1,5} |subtxt[0-9]{1,5} |lower |upper |ucfirst |ucwords |trim |url |json |js |html |css |nl2br |syntaxhtml// [@@@SUB-TEMPLATE:path/to/tpl.htm@@@] :: sub-template with relative path to template// [@@@SUB-TEMPLATE:?path/to/tpl.htm@@@] :: sub-template with relative path to template, optional, if exists// [@@@SUB-TEMPLATE:!etc/path/to/tpl.htm!@@@] :: sub-template with relative path to framework, using exact this path// [@@@SUB-TEMPLATE:?!if-exists/path/to/tpl.htm!@@@] :: sub-template with relative path to framework, using exact this path, optional, if exists// [@@@SUB-TEMPLATE:{tpl}|{escape}@@@] :: sub-template (using any kind of path from above), apply escape (any of): |syntax |syntaxhtml |html |js |js-tpl-encode |tpl-uri-encode |tpl-b64-encode// [@@@SUB-TEMPLATE:%variable%@@@] :: variable sub-template ; must be defined in $y_arr_vars['@SUB-TEMPLATES@'] array as key (variable) => value (path)// [%%%IF:TEST-VARIABLE:@==|@!=|@<=|@<|@>=|@>|==|!=|<=|<|>=|>|!%|%|!?|?|^~|^*|&~|&*|$~|$*{string/number/a|list|with|elements/###MARKER###};%%%] conditional IF part, display when condition is matched [%%%ELSE:TEST-VARIABLE%%%] conditional ELSE part, display otherwise (optional) [%%%/IF:TEST-VARIABLE%%%]// [%%%LOOP:ARR-VARIABLE%%%] [###ARR-VARIABLE.ID|int###]. [###ARR-VARIABLE.NAME|html###] [%%%/LOOP:ARR-VARIABLE%%%]// [%%%COMMENT%%%] This is a comment in template that will not be displayed [%%%/COMMENT%%%]// And some special characters:// [%%%|SB-L%%%] ensures a LEFT SQUARE BRACKET [// [%%%|SB-R%%%] ensures a RIGHT SQUARE BRACKET ]// [%%%|SPACE%%%] ensures a SPACE// [%%%|T%%%] ensures a TAB \t// [%%%|N%%%] ensures a LINE FEED \n// [%%%|R%%%] ensures a CARRIAGE RETURN \r
SmartMarkersTemplating::render_file_template(
'views/my-template.mtpl.htm',
[
'MARKER' => 'something ...',
'TEST-VARIABLE' => 'another thing !',
'ARR-VARIABLE' => [
[ 'id' => 1, 'name' => 'One' ],
[ 'id' => 2, 'name' => 'Two' ],
[ 'id' => 3, 'name' => 'Three' ]
]
]
);
// #end php code
class Properties
class Constants
documentation generated on: 2023-10-19 23:15:44 +0000