Permalink
Browse files

Merge pull request #2 from le-phare/master

Ok pour les modifs.
Merci
  • Loading branch information...
hugokernel committed Feb 24, 2012
2 parents 9a3d1e3 + 922906f commit acd2db8184e68f459517f07524411d3e0db653b8
Showing with 53 additions and 7 deletions.
  1. +5 −7 hyla_tpl.class.php
  2. +23 −0 tests/index.php
  3. +25 −0 tests/tpl/main.tpl
View
@@ -457,15 +457,13 @@ private function _parseFuncVar($val, $type) {
}
}
// Variable exists ?
if (array_key_exists($name, $this->vars)) {
// Default with "empty" value
if ($default !== null && (!array_key_exists($name, $this->vars) || !strlen($this->vars[$name]))) {
$value = $default;
} elseif (array_key_exists($name, $this->vars)) {
$value = $this->vars[$name];
} else {
if ($default !== null) {
$value = $default;
} else {
return ($this->remove_unknow_var) ? null : '{$' . $name . '}';
}
return ($this->remove_unknow_var) ? null : '{$' . $name . '}';
}
// Function
View
@@ -141,6 +141,29 @@ function hello($name = null) {
$t->render('block.always.called');
$lines = array(
0 => array(
'text' => null
),
1 => array(
'text' => ''
),
2 => array(
'text' => false
),
3 => array(
'text' => 0
),
4 => array(
'text' => 'some text'
),
);
foreach ($lines as $line) {
$t->setVar('line', $line);
$t->render('block_with_defaults');
}
// Affiche le résultat
echo $t->render();
View
@@ -67,6 +67,31 @@ Hyla_Tpl version {$VERSION}
</blockquote>
<!-- END b1 -->
<h2>Blocks with default values</h2>
<pre><code>
$lines = array(
0 => array(
'text' => null
),
1 => array(
'text' => ''
),
2 => array(
'text' => false
),
3 => array(
'text' => 0
),
4 => array(
'text' => 'some text'
)
);
</code></pre>
<!-- BEGIN block_with_defaults -->
<p>line = {$line.text (<span class="ok">(default value)</span>)}</p>
<!-- END block_with_defaults -->
<a href="?dir={$dir}&lang={$lang_switch}">{_Switch lang} : {$lang_switch}</a>
<table width="50%" id="tree">

0 comments on commit acd2db8

Please sign in to comment.