本文整理汇总了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);
}
示例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;
}
示例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);
}
}
示例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);
示例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;
}