本文整理汇总了PHP中Utilities::templateReplace方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::templateReplace方法的具体用法?PHP Utilities::templateReplace怎么用?PHP Utilities::templateReplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utilities
的用法示例。
在下文中一共展示了Utilities::templateReplace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renders a template file
* @params string $template - path of template file
* @params assoc-array $args - associative array with the to be replaced values
*/
public function render($template, $args)
{
if (!file_exists($template)) {
throw new Exception('The template "' . $template . '" does not exist');
}
$html = Utilities::getFileContent($template);
$html = Utilities::templateReplace($html, $args, static::$var_prefix, static::$var_suffix);
return $html;
}
示例2: translate
public static function translate($key, $args = array())
{
$inst = I18N::instance();
if (!array_key_exists($key, static::$translations[static::$lang])) {
$val = $key;
} else {
$val = static::$translations[static::$lang][$key];
}
$GLOBALS['debug'] = true;
return Utilities::templateReplace($val, $args);
}
示例3: pagination
public static function pagination($current, $max, $page_size, $link, $prevnext = 2)
{
$min_page = $current - $prevnext;
$max_page = ceil($max / $page_size);
$start = max($min_page, 0);
$end = (int) min($max_page, $start + 1 + 2 * $prevnext);
$links = array();
for ($now = $start; $now < $end; $now++) {
$links[] = array('label' => $now + 1, 'link' => Utilities::templateReplace($link, array('page' => $now)), 'current' => $now == $current);
}
$args = array('start' => array('label' => '<<', 'link' => Utilities::templateReplace($link, array('page' => 0)), 'current' => false), 'links' => $links, 'end' => array('label' => '>>', 'link' => Utilities::templateReplace($link, array('page' => $end - 1)), 'current' => false), 'current' => $current, 'canPrev' => $current != 0 && $start != 0, 'canNext' => $current != $end - 1 && $end != $max_page);
$pagination = TemplateRenderer::instance()->extendedRender('theme/templates/snippets/pagination.html', $args);
return $pagination;
}
示例4: _queryTemplate
protected function _queryTemplate($template, $args)
{
return Utilities::templateReplace($template, $args, '{%', '%}');
}