File: lib/plugins/inlinemodifier.default.php

Recommend this page to a friend!
  Classes of David Tamas  >  g-template-php  >  lib/plugins/inlinemodifier.default.php  >  Download  
File: lib/plugins/inlinemodifier.default.php
Role: Example script
Content type: text/plain
Description: Example script
Class: g-template-php
Process and render templates generating PHP code
Author: By
Last change:
Date: 2 years ago
Size: 736 bytes
 

 

Contents

Class file image Download
<?php
/**
 * gTemplate Plugins
 *
 * @package gTemplate
 * @subpackage Plugins
 */

/**
 * gTemplate cat modifier plugin
 *
 * Type: inlinemodifier<br>
 * Name: default<br>
 * Purpose: designate default value for empty variables<br>
 * Example: {$var|default:"foo"}
 *
 * @version 1.0
 * @author Tamas David (G-Lex) <glex at mittudomain.info>
 * @link https://github.com/glex86/g-template-php G-Template Engine on Github
 */
function tpl_inlinemodifier_default($variable, $arguments, &$gTpl)
{
    if (!
$arguments[0]) {
       
$gTpl->trigger_error("[SYNTAX] 'cat' modifier requires one parameter", E_USER_NOTICE, $object->_file, $object->_linenum);
    }

    return
"(string)$variable===''?{$arguments[0]}:$variable";
}


For more information send a message to info at phpclasses dot org.