当前位置: 首页>>代码示例>>PHP>>正文


PHP Haanga::compile方法代码示例

本文整理汇总了PHP中Haanga::compile方法的典型用法代码示例。如果您正苦于以下问题:PHP Haanga::compile方法的具体用法?PHP Haanga::compile怎么用?PHP Haanga::compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Haanga的用法示例。


在下文中一共展示了Haanga::compile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLambda

 /** 
  * @dataProvider tplProvider
  */
 public function testLambda($test_file, $data, $expected)
 {
     $this->init($test_file, $expected);
     $callback = Haanga::compile(file_get_contents($test_file), $data);
     $output = $callback($data);
     $this->assertEquals($output, $expected);
 }
开发者ID:kuslahne,项目名称:Haanga,代码行数:10,代码来源:templateTest.php

示例2: match

 public function match($uri)
 {
     global $conf;
     global $localUri;
     global $uri;
     global $acceptContentType;
     global $endpoints;
     global $lodspk;
     global $results;
     global $firstResults;
     require_once $conf['home'] . 'classes/MetaDb.php';
     $metaDb = new MetaDb($conf['metadata']['db']['location']);
     $pair = Queries::getMetadata($localUri, $acceptContentType, $metaDb);
     if ($pair == NULL) {
         // Original URI is not in metadata
         if (Queries::uriExist($uri, $endpoints['local'])) {
             $page = Queries::createPage($uri, $localUri, $acceptContentType, $metaDb);
             if ($page == NULL) {
                 HTTPStatus::send500("Can't write sqlite database.");
             }
             HTTPStatus::send303($page, $acceptContentType);
             exit(0);
         } else {
             return false;
         }
     }
     list($res, $page, $format) = $pair;
     $uri = $res;
     $queries = $this->getQueries();
     $e = $endpoints['local'];
     require_once $conf['home'] . 'lib/Haanga/lib/Haanga.php';
     Haanga::configure(array('cache_dir' => $conf['home'] . 'cache/', 'autoescape' => FALSE));
     $vars = compact('uri', 'lodspk', 'models', 'first');
     foreach ($queries as $l => $v) {
         $q = Utils::addPrefixes(file_get_contents($v));
         $fnc = Haanga::compile($q);
         $query = $fnc($vars, TRUE);
         $aux = $e->query($query, Utils::getResultsType($query));
         if ($aux["boolean"] === true) {
             $pair[] = $l;
             return $pair;
         }
     }
     return false;
 }
开发者ID:narock,项目名称:lodspeakr,代码行数:45,代码来源:sparqlFilterModule.php

示例3: showView

 public static function showView($lodspkData, $data, $view)
 {
     global $conf;
     global $uri;
     global $lodspk;
     global $extension;
     //$lodspk = $conf['view']['standard'];
     $lodspk = $lodspkData;
     if (isset($lodspkData['params'])) {
         $lodspk['this']['params'] = $lodspkData['params'];
     }
     if (isset($lodspk['queryTimes'])) {
         $lodspk['queryTimes'] = Convert::array_to_object($lodspk['queryTimes']);
     }
     require_once $conf['home'] . 'lib/Haanga/lib/Haanga.php';
     $viewAux = explode("/", $view);
     $viewFile = array_pop($viewAux);
     //$viewFile = $view;
     $viewPath = join("/", $viewAux);
     Haanga::configure(array('template_dir' => $viewPath, 'cache_dir' => $conf['home'] . 'cache/'));
     $rdf = null;
     if (array_key_exists('rdf', $data)) {
         $rdf = $data['rdf'];
         unset($data['rdf']);
     } else {
     }
     $models = $data;
     Convert::getPaths($models, "");
     $first = $lodspk['firstResults'];
     unset($lodspk['firstResults']);
     //unset($lodspk);
     $vars = compact('uri', 'lodspk', 'conf', 'models', 'rdf', 'first');
     if ($conf['debug']) {
         //Logging::log(var_export($vars, true));
     }
     if (is_string($data)) {
         echo $data;
     } elseif (is_file($view)) {
         try {
             Haanga::Load($viewFile, $vars);
         } catch (Exception $e) {
             echo '<pre>';
             echo $e->getMessage() . "' in " . $e->getFile() . ":" . $e->getLine() . "\nStack trace:\n" . $e->getTraceAsString();
             echo '</pre>';
         }
     } elseif ($view == null) {
         $fnc = Haanga::compile('{{models|safe}}');
         $fnc($vars, TRUE);
     } else {
         echo $conf['home'] . $viewPath . " " . $viewFile;
         $fnc = Haanga::compile($view);
         $fnc($vars, TRUE);
     }
 }
开发者ID:OpenDataServices,项目名称:lodspeakr,代码行数:54,代码来源:Utils.php

示例4: PHP

<?php

require "../lib/Haanga.php";
$fnc = Haanga::compile(<<<EOT
    <h1>{{foobar}}{{    foobar  }}</h1>

    Este template será compilado a una función PHP ({{foo|default:foobar}})


EOT
);
$fnc(array("foobar" => 'hola', 'foo' => '.I.'), FALSE);
$fnc(array("foobar" => 'chau'), FALSE);
开发者ID:crodas,项目名称:haanga,代码行数:13,代码来源:template_runtime.php

示例5: generate

 public function generate($name, $data)
 {
     if (!class_exists("Haanga")) {
         throw new \RuntimeException("The library 'Haanga' is not loaded for UI Generator!");
     }
     if (($default = $this->getDefConf('default_block')) !== '') {
         $this->defaultBlock = $default;
     }
     $this->currentBlock = $this->getBlock($name);
     $this->currentBlockName = $name;
     $this->data = $data;
     $generated = array();
     foreach ($this->currentBlock as $varName => $template) {
         $fn = \Haanga::compile($template);
         try {
             $generatedContent = $fn($data);
             if ($varName == 'html') {
                 $generatedContent = $this->enableMinify ? self::minifyHtml($fn($data)) : $fn($data);
             }
             $generated[$varName] = $generatedContent;
         } catch (\Exception $e) {
             throw new \Exception('Alchemy\\Component\\UI\\Parse:: ' . $e->getMessage());
         }
     }
     return $generated;
 }
开发者ID:phpalchemy,项目名称:phpalchemy,代码行数:26,代码来源:Parser.php


注:本文中的Haanga::compile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。