本文整理汇总了PHP中Mustache_Engine::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Mustache_Engine::render方法的具体用法?PHP Mustache_Engine::render怎么用?PHP Mustache_Engine::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mustache_Engine
的用法示例。
在下文中一共展示了Mustache_Engine::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderFile
public function renderFile($templateNames, $data)
{
$this->ensureLoaded();
$templatePath = null;
foreach ($templateNames as $templateName) {
echo $this->mustache->render($templateName, $data);
}
}
示例2: render
/**
* Render a template
*
* @param string $source The template path or content
* @param array $data An associative array of data to be extracted in local template scope
* @throws \RuntimeException If the template could not be loaded
* @return string The rendered template
*/
public function render($source, array $data = array())
{
parent::render($source, $data);
//Let mustache load the template by proxiing through the load() method.
$result = $this->_mustache->render($source, $data);
//Render the debug information
return $this->renderDebug($result);
}
示例3: renderTemplate
/**
* @param $_pageContent : Contenu à "templater"
* @param null $_data : Source de données optionnelle
*/
function renderTemplate($_pageContent, $_data = null)
{
// Ajout des constantes de chemin absolu
$_data["PUBLIC_ABSOLUTE_PATH"] = PUBLIC_ABSOLUTE_PATH;
$_data["SERVER_ABSOLUTE_PATH"] = SERVER_ABSOLUTE_PATH;
$mustache = new Mustache_Engine();
// Favicons
$_data["favicons"] = $mustache->render(file_get_contents("public/html/favicons.html"), $_data);
echo $mustache->render($_pageContent, $_data);
}
示例4: render
/**
* {@inheritdoc}
*
* @param string $path
* @param array $params
* @param boolean $mustClean
*/
public function render($path, $params, $mustClean = false)
{
if (!isset($params['content'])) {
$params['content'] = $this->_view->getContent();
}
$content = $this->mustache->render(file_get_contents($path), $params);
if ($mustClean) {
$this->_view->setContent($content);
} else {
echo $content;
}
}
示例5: render
/**
* {@inheritdoc}
*
* @param string $path
* @param array $params
* @param boolean $mustClean
*/
public function render($path, $params, $mustClean = false)
{
if (!isset($params['content'])) {
$params['content'] = $this->_view->getContent();
}
$tplContent = $this->getCachedTemplate($path);
$content = $this->mustache->render("{{%FILTERS}}\n" . $tplContent, $params);
if ($mustClean) {
$this->_view->setContent($content);
} else {
echo $content;
}
}
示例6: render
public function render()
{
$m = new \Mustache_Engine();
$template = $this->template->contents();
$output = $m->render($template, $this->context);
$this->output->write($output);
}
示例7: render
/**
* Render the output for this module (out.ctp).
*
* @param BasicThemeView $view
* @return string
*/
public function render($view)
{
if (method_exists($this, 'beforeRender')) {
$this->beforeRender();
}
if (method_exists($this, 'getContext')) {
$contextClass = $this->getContext();
$context = new $contextClass($view, $this->data);
$template = $this->path() . DS . 'out.mustache';
} else {
$template = $this->path() . DS . 'out.ctp';
}
if (!file_exists($template)) {
user_error(__d('wasabi_cms', 'Template "{0}" for module {1} not found.', $template, $this->name()));
}
if (isset($context)) {
if (!$this->_mustache) {
$this->_mustache = new \Mustache_Engine();
}
$output = $this->_mustache->render(file_get_contents($template), $context);
} else {
$output = $view->element('Wasabi/Cms.module', ['template' => $template, 'data' => $this->data]);
}
return $output;
}
示例8: render
public function render($template, $data=true)
{
$data=$this->createView($data);
return $this->m->render("{{# render}}$template{{/ render}}",[
'session'=>[
'debug'=>DEBUG,
'hc'=>
$this->api->estAuthentifier()?
$this->api->compteConnecte()->contraste:
false,
'pages'=>$this->api->API_pages_lister(),
'compte'=>$this->api->compteConnecte(),
'estAuthentifier'=>$this->api->estAuthentifier(),
'estAdministrateur'=>$this->api->estAdmin(),
'estDesactive'=>$this->api->estDésactivé(),
'estLibreService'=>$this->api->estLibreService(),
'estNouveau'=>$this->api->estNouveau(),
//'estPanier'=>$this->api->estPanier(),
//'estPremium'=>$this->api->estPremium(),
'peutCommander'=>$this->api->peutCommander(),
'peutModifierCommande'=>function($value){
return $this->api->peutModifierCommande($value);
}
],
'data'=>$data
]);
}
示例9: show_news
public static function show_news($folder = 'posts', $template = 'templates')
{
$m = new Mustache_Engine();
$files = glob("{$folder}/*.md");
/** /
usort($files, function($a, $b) {
return filemtime($a) < filemtime($b);
});
/**/
$html = '';
foreach ($files as $file) {
$route = substr($file, strlen($folder) + 1, -3);
$page = new FrontMatter($file);
$title = $page->fetch('title') != '' ? $page->fetch('title') : $route;
$date = $page->fetch('date');
$author = $page->fetch('author');
$description = $page->fetch('description') == '' ? '' : $page->fetch('description');
$data[] = array('title' => $title, 'route' => $route, 'author' => $author, 'description' => $description, 'date' => $date);
}
/**/
function date_compare($a, $b)
{
$t1 = strtotime($a['date']);
$t2 = strtotime($b['date']);
return $t1 - $t2;
}
usort($data, 'date_compare');
$data = array_reverse($data);
/**/
$template = file_get_contents('templates/show_news.tpl');
$data['files'] = $data;
return $m->render($template, $data);
return $html;
}
示例10: render
/**
* Renders a template using Mustache.php.
*
* @see View::render()
* @param string $template The template name specified in Slim::render()
* @return string
*/
public function render($template)
{
require_once self::$mustacheDirectory . '/Autoloader.php';
\Mustache_Autoloader::register(dirname(self::$mustacheDirectory));
$m = new \Mustache_Engine();
$contents = file_get_contents($this->getTemplatesDirectory() . '/' . ltrim($template, '/'));
return $m->render($contents, $this->data);
}
示例11: generate
/**
* Generate the objects and factories
*/
public function generate()
{
$this->readyDestinationDirectory();
$tableSchemas = (new SchemaGenerator($this->connection))->getTableSchemas();
// @codeCoverageIgnoreStart
if ($tableSchemas === null || count($tableSchemas) === 0) {
throw new \Parm\Exception\ErrorException("No tables in database.");
}
// @codeCoverageIgnoreEnd
$globalNamespaceData['tables'] = [];
$globalNamespaceData['namespace'] = $this->generateToNamespace;
$globalNamespaceData['escapedNamespace'] = $this->generateToNamespace != "" ? str_replace("\\", "\\\\", $this->generateToNamespace) . "\\\\" : '';
$globalNamespaceData['namespaceLength'] = strlen($this->generateToNamespace) + 1;
foreach ((new SchemaGenerator($this->connection))->getTableSchemas() as $tableName => $schema) {
$globalNamespaceData['tables'][] = ['className' => ucfirst(\Parm\Row::columnToCamelCase($tableName))];
$data = $this->getTemplatingDataFromSchema($schema);
$m = new \Mustache_Engine();
$this->writeContentsToFile(rtrim($this->destinationDirectory, '/') . '/' . $data['className'] . 'Table.php', $m->render(file_get_contents(dirname(__FILE__) . '/templates/table_interface.mustache'), $data));
$this->writeContentsToFile(rtrim($this->destinationDirectory, '/') . '/' . $data['className'] . 'TableFunctions.php', $m->render(file_get_contents(dirname(__FILE__) . '/templates/table_trait.mustache'), $data));
$this->writeContentsToFile(rtrim($this->destinationDirectory, '/') . '/' . $data['className'] . 'DaoObject.php', $m->render(file_get_contents(dirname(__FILE__) . '/templates/dao_object.mustache'), $data));
$this->writeContentsToFile(rtrim($this->destinationDirectory, '/') . '/' . $data['className'] . 'DaoFactory.php', $m->render(file_get_contents(dirname(__FILE__) . '/templates/dao_factory.mustache'), $data));
// global namespace file
if ($this->generateToNamespace != "\\" && $this->generateToNamespace != "") {
$this->writeContentsToFile(rtrim($this->destinationDirectory, '/') . '/alias_all_tables_to_global_namespace.php', $m->render(file_get_contents(dirname(__FILE__) . '/templates/alias_all_tables_to_global_namespace.mustache'), $globalNamespaceData));
$this->writeContentsToFile(rtrim($this->destinationDirectory, '/') . '/autoload.php', $m->render(file_get_contents(dirname(__FILE__) . '/templates/namespaced_autoload.mustache'), $globalNamespaceData));
} else {
$this->writeContentsToFile(rtrim($this->destinationDirectory, '/') . '/autoload.php', $m->render(file_get_contents(dirname(__FILE__) . '/templates/global_autoload.mustache'), $globalNamespaceData));
}
}
}
示例12: mustacheRender
public static function mustacheRender($template, $values)
{
TemplateEngine::getMustacheInstance();
$m = new Mustache_Engine();
//
$response = $m->render($template, $values);
// $response = preg_replace('/[\s\t\n\r\s]+/', ' ', $response);
return $response;
}
示例13: render
public function render($filename, $tplvars = false, $nodisplay = false)
{
$data = $this->mergeData($tplvars);
$tpl = parent::render($filename, $data);
if ($nodisplay) {
return $tpl;
} else {
echo $tpl;
}
}
示例14: register
function register()
{
if ('POST' == $_SERVER['REQUEST_METHOD']) {
//stocke les valeurs
$email = strtolower($_POST["txtMail"]);
$firstName = $_POST["txtFirstName"];
$lastName = $_POST["txtLastName"];
$phone = $_POST["txtPhone"];
$pass = $_POST["txtPassword"];
$passCheck = $_POST["txtPasswordConfirm"];
if (!empty($_POST["txtMail"]) and !empty($_POST["txtFirstName"]) and !empty($_POST["txtLastName"]) and !empty($_POST["txtPhone"]) and !empty($_POST["txtPassword"])) {
//modifier le numéro de téléphone afin de correspondre à la BD
$phone = self::normalizePhoneNumber($phone);
//vérifier si informations valides (email + pass)
if (Users::getUserIdByName($email) == -1 && $pass == $passCheck) {
$salt = self::generateSalt();
$crypt = crypt($pass, $salt);
$userId = Users::addFamilyOwner($email, $phone, $firstName, $lastName, $crypt, $salt);
$owner = $userId;
$name = "Contenant principal";
$parent = null;
$value = 0;
$initValue = 0;
$warranty = "";
$infos = "";
$summary = "Contenant de départ";
$public = 1;
$quantity = 1;
Objects::addObject($name, $owner, $parent, $value, $initValue, $warranty, $infos, $summary, $public, $quantity);
header(CONNECTION_HEADER . '/registration');
if (isset($userId)) {
$user = Users::getUser($userId);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$to = "";
$recipients = Users::getAllAdminMail();
foreach ($recipients as $recipient) {
$to .= $recipient . ', ';
}
substr($to, 0, -2);
$subject = "Nouvelle demande de patrimoine";
$data = array('path' => SERVER_ABSOLUTE_PATH . "/sysadmin", 'user' => $user["UserName"], 'img' => PUBLIC_ABSOLUTE_PATH . "/assets/logo_petit.png");
$mustache = new Mustache_Engine();
mail($to, $subject, $mustache->render(file_get_contents('public/html/mailtemplateregistration.html'), $data), $headers . "From: " . SENDING_EMAIL);
}
} else {
$data = array("SERVER_ABSOLUTE_PATH" => SERVER_ABSOLUTE_PATH, "PUBLIC_ABSOLUTE_PATH" => PUBLIC_ABSOLUTE_PATH, "Error" => true, "ErrorMSG" => Users::getUserIdByName($email) != -1 ? "Adresse courriel déjà en utilisation" : "Vous devez saisir le même mot de passe", "FirstName" => $firstName, "LastName" => $lastName, "Phone" => $phone, "Email" => $email);
$this->renderTemplate(file_get_contents(REGISTRATION_PAGE), $data);
}
} else {
$data = array("SERVER_ABSOLUTE_PATH" => SERVER_ABSOLUTE_PATH, "PUBLIC_ABSOLUTE_PATH" => PUBLIC_ABSOLUTE_PATH, "Error" => true, "ErrorMSG" => "Informations manquantes", "FirstName" => $firstName, "LastName" => $lastName, "Phone" => $phone, "Email" => $email);
$this->renderTemplate(file_get_contents(REGISTRATION_PAGE), $data);
}
}
}
示例15: render
static function render($view, $data)
{
global $aplication;
global $debugbar;
$app = $aplication->getApp();
$path = $app->getViews();
Mustache_Autoloader::register();
$options = array('extension' => '.mustache');
$template = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader($path, $options)));
echo $template->render($view, $data);
}