コード例 #1
1
ファイル: Templatr.php プロジェクト: bahulneel/php-templatr
 public function render()
 {
     $m = new \Mustache_Engine();
     $template = $this->template->contents();
     $output = $m->render($template, $this->context);
     $this->output->write($output);
 }
コード例 #2
0
    public function testLambdasInsidePartialsAreIndentedProperly()
    {
        $src = <<<EOS
<fieldset>
  {{> input }}
</fieldset>

EOS;
        $partial = <<<EOS
<input placeholder="{{# _t }}Enter your name{{/ _t }}">

EOS;

        $expected = <<<EOS
<fieldset>
  <input placeholder="ENTER YOUR NAME">
</fieldset>

EOS;

        $m = new Mustache_Engine(array(
            'partials' => array('input' => $partial)
        ));

        $tpl = $m->loadTemplate($src);

        $data = new Mustache_Test_Functional_ClassWithLambda();
        $this->assertEquals($expected, $tpl->render($data));
    }
コード例 #3
0
ファイル: CawMustache.php プロジェクト: corvum/caw
 protected function renderHTML()
 {
     $dir = rtrim($this->viewDir);
     $mustache = new \Mustache_Engine(['loader' => new \Mustache_Loader_FilesystemLoader($dir)]);
     $template = $mustache->loadTemplate($this->view);
     return $template->render($this->data);
 }
コード例 #4
0
 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;
 }
コード例 #5
0
ファイル: render.php プロジェクト: myklv/asana-lite
/**
 * render() takes a view name, and a model and renders a mustache template
 *
 * @param $view  string  The view name, which will be used to fetch the actual view
 * @param $model array   An array containing all of the fields that will be passed to mustache for render
 *
 * @return string
 */
function render($view, $model)
{
    $m = new Mustache_Engine(['loader' => new Mustache_Loader_FilesystemLoader(PREFIX . '/views')]);
    $tpl = $m->loadTemplate($view);
    header("Content-Type: text/html; charset=utf-8");
    echo minify_output($tpl->render($model));
}
コード例 #6
0
ファイル: RoboFile.php プロジェクト: rarst/laps
 /**
  * Compiles plugin's mustache template
  */
 public function makeMustache()
 {
     $dir = __DIR__ . '/views/cache';
     $this->_cleanDir($dir);
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader(__DIR__ . '/views'), 'cache' => $dir));
     $mustache->loadTemplate('laps');
 }
コード例 #7
0
 /**
  * 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);
 }
コード例 #8
0
ファイル: init.php プロジェクト: raulmontejo/vimeography
 /**
  * Action target that displays the popup to insert a form to a post/page.
  *
  * @access public
  * @return void
  */
 public function vimeography_add_mce_popup()
 {
     $mustache = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader(VIMEOGRAPHY_PATH . 'lib/admin/templates')));
     require_once VIMEOGRAPHY_PATH . 'lib/admin/controllers/vimeography/mce.php';
     $view = new Vimeography_MCE();
     $template = $mustache->loadTemplate('vimeography/mce');
     echo $template->render($view);
 }
コード例 #9
0
ファイル: mustache.php プロジェクト: nooku/nooku-framework
 /**
  * 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);
 }
コード例 #10
0
 /**
  * Uma action nesse contexto representa o link que executa uma ação específica
  * em um grid, específicamente na última coluna do grid, na coluna AÇÕES.
  * 
  * @param Mustache_Engine $mustache
  * @param array $row
  */
 public function getActions($mustache, $row)
 {
     $actions = "";
     foreach ($this->actions as $config) {
         $actions .= "  " . HTML::link($mustache->renderHTML($config['url'], $row), '<span class="' . $config['icon_class'] . '"></span> ' . $config['label_text'] . '  ', $config['title'], $config['extra']);
     }
     return $actions;
 }
コード例 #11
0
ファイル: CallTest.php プロジェクト: samplex/shorturl
 public function testCallEatsContext()
 {
     $m = new Mustache_Engine();
     $tpl = $m->loadTemplate('{{# foo }}{{ label }}: {{ name }}{{/ foo }}');
     $foo = new Mustache_Test_Functional_ClassWithCall();
     $foo->name = 'Bob';
     $data = array('label' => 'name', 'foo' => $foo);
     $this->assertEquals('name: Bob', $tpl->render($data));
 }
コード例 #12
0
ファイル: TemplateEngine.php プロジェクト: alex2stf/phpquick
 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
0
ファイル: pg_builder.php プロジェクト: TheDoxMedia/pgs
 public static function page($arr, $templ_short)
 {
     $mustache = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader(dirname(__DIR__) . '/templ/')));
     // Add urls into Arr
     $arr['mainUrl'] = main_url;
     $arr['siteUrl'] = site_url;
     $_templ = $mustache->loadTemplate($templ_short);
     echo $_templ->render($arr);
 }
コード例 #14
0
 /**
  * Get a Mustache object.
  *
  * @param   Container  $c  A DI container.
  *
  * @return  \Mustache_Engine
  *
  * @since   2.0
  */
 public function getMustache(Container $c)
 {
     $config = $c->get('config');
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader($config->get('mustache.views', __DIR__ . '/../templates'), array('extension' => $config->get('mustache.ext', '.md')))));
     $mustache->addHelper('number', array('1f' => function ($value) {
         return sprintf('%.1f', $value);
     }));
     return $mustache;
 }
コード例 #15
0
 /**
  * @group wip
  * @dataProvider strictCallables
  */
 public function testStrictCallablesEnabled($name, $section, $expected)
 {
     $mustache = new Mustache_Engine(array('strict_callables' => true));
     $tpl = $mustache->loadTemplate('{{# section }}{{ name }}{{/ section }}');
     $data = new StdClass();
     $data->name = $name;
     $data->section = $section;
     $this->assertEquals($expected, $tpl->render($data));
 }
コード例 #16
0
ファイル: Html.php プロジェクト: aoloe/php-senape
 public function getAddComment()
 {
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader($this->path_template), 'helpers' => array('i18n' => \Aoloe\Senape\I18n::getInstance($this->settings))));
     $template = $mustache->loadTemplate('comment-form-add');
     // \Aoloe\debug('settings', $this->settings);
     // TODO: translating in the template or here in php before handing over to the template?
     // TODO: pass the current values once and if we have them
     return $template->render(array('has-labels' => false, 'site-current' => $this->settings['senape-site-current'], 'page-current' => $this->settings['senape-page-current'], 'comment-last-id' => null));
 }
コード例 #17
0
ファイル: controller.php プロジェクト: Swapon444/Patrimoine
 /**
  * @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);
 }
コード例 #18
0
 /**
  * @dataProvider cacheLambdaTemplatesData
  */
 public function testCacheLambdaTemplatesOptionWorks($dirName, $tplPrefix, $enable, $expect)
 {
     $cacheDir = $this->setUpCacheDir($dirName);
     $mustache = new Mustache_Engine(array('template_class_prefix' => $tplPrefix, 'cache' => $cacheDir, 'cache_lambda_templates' => $enable));
     $tpl = $mustache->loadTemplate('{{#wrap}}{{name}}{{/wrap}}');
     $foo = new Mustache_Test_Functional_Foo();
     $foo->wrap = array($foo, 'wrapWithEm');
     $this->assertEquals('<em>' . $foo->name . '</em>', $tpl->render($foo));
     $this->assertCount($expect, glob($cacheDir . '/*.php'));
 }
コード例 #19
0
ファイル: registration.php プロジェクト: Swapon444/Patrimoine
 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);
         }
     }
 }
コード例 #20
0
 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);
 }
コード例 #21
0
ファイル: Mustache.php プロジェクト: nineeshk/incubator
 /**
  * {@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;
     }
 }
コード例 #22
0
ファイル: Layout.php プロジェクト: MaitreyaBuddha/worklist
 public function render($view)
 {
     if (!is_subclass_of($this, 'Layout')) {
         return;
     }
     $name = $this->name;
     $base = VIEWS_DIR . DIRECTORY_SEPARATOR . 'layout' . DIRECTORY_SEPARATOR . 'mustache';
     $partials = VIEWS_DIR . DIRECTORY_SEPARATOR . 'mustache' . DIRECTORY_SEPARATOR . 'partials';
     $mustache = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader($base), 'partials_loader' => new Mustache_Loader_FilesystemLoader($partials)));
     $template = $mustache->loadTemplate($this->name);
     return $template->render($view);
 }
コード例 #23
0
 public function generateBlog()
 {
     set_time_limit(0);
     global $app;
     $this->parser = new \Parsedown();
     $data = $this->getData();
     $layout = $data['settings']['layout'] ?: 'default';
     $layoutDir = $app->view->getData('layoutsDir') . $layout . '/';
     // first copy all contents of template to public folder
     copy_directory($layoutDir, $this->publicDir);
     // now create actual html pages
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader($layoutDir), 'partials_loader' => new \Mustache_Loader_FilesystemLoader($layoutDir . '/partials')));
     $mustacheFiles = glob($layoutDir . '/*.mustache');
     $excludedFiles = array('category', 'post', 'page', 'archive', 'tag');
     foreach ($mustacheFiles as $mustacheFile) {
         $fileName = basename($mustacheFile);
         $fileName = str_replace('.mustache', '', $fileName);
         // we will generate these later
         if (true === in_array($fileName, $excludedFiles)) {
             continue;
         }
         $template = $mustache->loadTemplate($fileName);
         $html = $template->render($data);
         file_put_contents($this->publicDir . $fileName . '.html', $html);
     }
     // delete mustache particals folders from public folder
     rrmdir($this->publicDir . 'partials/');
     // delete *.mustache from public dir
     $mustacheFiles = glob($this->publicDir . '/*.mustache');
     foreach ($mustacheFiles as $mustacheFile) {
         @unlink($mustacheFile);
     }
     // generate post files
     $this->generatePostPageFiles($mustache, $data, 'post');
     // generate page files
     $this->generatePostPageFiles($mustache, $data, 'page');
     // generate category and tag files
     $this->generateCategoryTagFiles($mustache, $data, 'category');
     $this->generateCategoryTagFiles($mustache, $data, 'tag');
     // generate archive files
     $this->generateArchiveFiles($mustache, $data);
     // generate RSS file
     $this->generateRSS($data);
     // generate sitemap.xml
     $this->generateSitemap($data);
     // copy blog data file
     copy('data/blog.json', 'public/data/blog.json');
     $message = '';
     $message .= 'Blog has been generated in <strong>public</strong> folder :)<br><br>';
     $message .= '<a id="viewGenLog" class="btn btn-primary">View Log</a><br><br>';
     $message .= '<div id="genlog">' . $this->getGenerateLog($this->generateLog) . '</div>';
     echo $message;
 }
コード例 #24
0
ファイル: Mustache.php プロジェクト: arroyo/erdiko
 /** 
  * Example playing with mustache templates
  * the $string variable would really be a view, but it's good to see here.
  */
 public function getMustache()
 {
     $string = "Hello, {{ planet }}!\n            {{# get_region }}two{{/ get_region }}\n            {{# get_region }}'three'{{/ get_region }}\n            {{# index }}four{{/ index }}\n            {{# getMustacheTest2 }}five{{/ getMustacheTest2 }}\n            ";
     $m = new \Mustache_Engine();
     $data = array('planet' => 'world', 'get_region' => function ($name) {
         return $this->getMustacheTest($name);
     }, 'index' => function () {
         return $this->getMustacheTest2();
     });
     $content = $m->render($string, $data);
     $this->setTitle('Mustache');
     $this->setContent($content);
 }
コード例 #25
0
ファイル: utils.php プロジェクト: diogok/biodiv-ui
function view($name, $props)
{
    if (isset($_SERVER['HTTP_ACCEPTS']) && $_SERVER['HTTP_ACCEPTS'] == 'application/json') {
        header('Content-Type: application/json');
        foreach ($props as $k => $v) {
            if (preg_match('/json/', $k)) {
                unset($props[$k]);
            } else {
                if (is_object($props[$k]) || is_array($props[$k])) {
                    foreach ($props[$k] as $kk => $vv) {
                        if (preg_match('/json/', $kk)) {
                            unset($props[$k][$kk]);
                        }
                    }
                }
            }
        }
        return json_encode($props);
    }
    $partials = [];
    $iterator = new \DirectoryIterator(__DIR__ . "/../templates");
    foreach ($iterator as $file) {
        if ($file->isFile() && preg_match("/\\.mustache\$/", $file->getFilename())) {
            $partials[substr($file->getFilename(), 0, -9)] = file_get_contents($file->getPath() . "/" . $file->getFilename());
        }
    }
    $base = getenv('BASE');
    if ($base == null) {
        $base = "";
    }
    $props['base'] = $base;
    if (isset($_SESSION['lang'])) {
        $props['strings'] = json_decode(file_get_contents(__DIR__ . '/../lang/' . $_SESSION['lang'] . '.json'));
    } else {
        $props['strings'] = json_decode(file_get_contents(__DIR__ . '/../lang/en.json'));
    }
    $template = file_get_contents(__DIR__ . '/../templates/' . $name . '.mustache');
    $m = new \Mustache_Engine(array('partials' => $partials));
    $m->addHelper('json', function ($v) {
        return json_encode($v);
    });
    $m->addHelper('geojson', function ($v) {
        if ($v != null) {
            return json_encode($v);
        } else {
            return '{"features":[],"type":"FeatureCollection"}';
        }
    });
    $content = $m->render($template, $props);
    return $content;
}
コード例 #26
0
ファイル: Mustache.php プロジェクト: mikejestes/ornamental
 public function renderString($string, $templateData)
 {
     if ($this->settings->partialDir) {
         $partialDir = $this->settings->partialDir;
     } else {
         $partialDir = $this->settings->templateDir . 'partials/';
     }
     $options = array();
     if (is_dir($partialDir)) {
         $options['partials_loader'] = new \Mustache_Loader_FilesystemLoader($partialDir);
     }
     $mustacheEngine = new \Mustache_Engine($options);
     return $mustacheEngine->render($string, $templateData);
 }
コード例 #27
0
 /**
  * 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));
         }
     }
 }
コード例 #28
0
 /**
  * Generate command class based on $args, $assocParams and $params
  * and put content in Command.php file in global cache wp-cli path.
  *
  * @return void
  */
 public static function generateCommandClass()
 {
     $args = \ViewOne\WPCLIEnvironment\Command::getArguments();
     $assocParams = \ViewOne\WPCLIEnvironment\Command::getAssocParameters();
     $params = \ViewOne\WPCLIEnvironment\Command::getParameters();
     $moutstache = new \Mustache_Engine();
     $dir = self::getCachePath();
     if (!file_exists($dir . '/wp-cli-environment')) {
         mkdir($dir . '/wp-cli-environment', 0777, true);
     }
     $template = file_get_contents(__DIR__ . '/../../../template/command.mustache');
     $variables = array('args' => $args, 'assoc_params' => $assocParams, 'params' => $params);
     $class = $moutstache->render($template, $variables);
     file_put_contents($dir . '/wp-cli-environment/Command.php', $class);
 }
コード例 #29
0
ファイル: AjaxExample.php プロジェクト: rajesh28892/erdiko
 /**
  * Get
  */
 public function get($var = null)
 {
     if ($var != null) {
         // load action
         return $this->autoaction($var);
     }
     $m = new \Mustache_Engine();
     $test = $m->render('Hello, {{ planet }}!', array('planet' => 'world'));
     // Hello, world!
     // error_log("mustache = {$test}");
     // error_log("var: ".print_r($var, true));
     $data = array("hello", "world");
     $view = new \erdiko\core\View('examples/helloworld', $data);
     $this->setContent($view);
 }
コード例 #30
0
ファイル: Template.php プロジェクト: educakanchay/campus
 /**
  * Resolve a context value.
  *
  * Invoke the value if it is callable, otherwise return the value.
  *
  * @param mixed            $value
  * @param Mustache_Context $context
  * @param string           $indent
  *
  * @return string
  */
 protected function resolveValue($value, Mustache_Context $context, $indent = '')
 {
     if (($this->strictCallables ? is_object($value) : !is_string($value)) && is_callable($value)) {
         return $this->mustache->loadLambda((string) call_user_func($value))->renderInternal($context, $indent);
     }
     return $value;
 }