Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: lib/Haanga/Compiler/Parser.php tests/assert_templates/trans.php
- Loading branch information
Showing
34 changed files
with
822 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: php | ||
script: cd tests/; phpunit TestSuite.php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
|
||
before_script: | ||
- curl -s http://getcomposer.org/installer | php | ||
- php composer.phar install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "crodas/Haanga", | ||
"description": "Template compiler for PHP, Django-style (as much as possible). Pretty efficent by avoiding to have anything at run-time.", | ||
"authors": [ | ||
{ | ||
"name": "César D. Rodas", | ||
"email": "crodas@php.net" | ||
} | ||
], | ||
"require": { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class Haanga_Extension_Filter_IsArray | ||
{ | ||
public $php_alias = "is_array"; | ||
public $is_safe = TRUE; /* boolean if safe */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
class Haanga_Extension_Filter_Null | ||
{ | ||
public $php_alias = 'is_null'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
class Haanga_Extension_Filter_Slugify | ||
{ | ||
static function generator($compiler, $args) | ||
{ | ||
if (count($args) != 1) { | ||
$compiler->Error("slugify filter only needs one parameter"); | ||
} | ||
|
||
$arg = hexec('strtolower', $args[0]); | ||
$arg = hexec('str_replace'," ","-",$arg); | ||
$arg = hexec('preg_replace',"/[^\d\w-_]/",'',$arg); | ||
return $arg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
class Haanga_Extension_Filter_Truncatechars | ||
{ | ||
static function main($text, $limit) | ||
{ | ||
if(strlen($text) <= $limit) | ||
return $text; | ||
$trunctext = substr($text, 0, $limit); | ||
$trunctext[$limit-3] = '.'; | ||
$trunctext[$limit-2] = '.'; | ||
$trunctext[$limit-1] = '.'; | ||
return $trunctext; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?php | ||
|
||
spl_autoload_register(function ($class) { | ||
/* | ||
This array has a map of (class => file) | ||
*/ | ||
|
||
// classes {{{ | ||
static $classes = array ( | ||
'haanga' => '/../Haanga.php', | ||
'haanga_ast' => '/AST.php', | ||
'haanga_extension_filter' => '/Extension/Filter.php', | ||
'haanga_extension' => '/Extension.php', | ||
'haanga_extension_tag_spaceless' => '/Extension/Tag/Spaceless.php', | ||
'haanga_extension_tag_exec' => '/Extension/Tag/Exec.php', | ||
'haanga_extension_tag_inline' => '/Extension/Tag/Inline.php', | ||
'haanga_extension_tag_upper' => '/Extension/Tag/Upper.php', | ||
'haanga_extension_tag_trans' => '/Extension/Tag/Trans.php', | ||
'haanga_extension_tag_templatetag' => '/Extension/Tag/Templatetag.php', | ||
'haanga_extension_tag_tryinclude' => '/Extension/Tag/Tryinclude.php', | ||
'haanga_extension_tag_setsafe' => '/Extension/Tag/Setsafe.php', | ||
'haanga_extension_tag_dictsort' => '/Extension/Tag/Dictsort.php', | ||
'haanga_extension_tag_min' => '/Extension/Tag/Min.php', | ||
'haanga_extension_tag_lower' => '/Extension/Tag/Lower.php', | ||
'haanga_extension_tag_currenttime' => '/Extension/Tag/Currenttime.php', | ||
'haanga_extension_tag_firstof' => '/Extension/Tag/Firstof.php', | ||
'haanga_extension_tag_buffer' => '/Extension/Tag/Buffer.php', | ||
'haanga_extension_tag_cycle' => '/Extension/Tag/Cycle.php', | ||
'haanga_extension_filter_urlencode' => '/Extension/Filter/Urlencode.php', | ||
'haanga_extension_filter_default' => '/Extension/Filter/Default.php', | ||
'haanga_extension_filter_length' => '/Extension/Filter/Length.php', | ||
'haanga_extension_filter_truncatechars' => '/Extension/Filter/Truncatechars.php', | ||
'haanga_extension_filter_intval' => '/Extension/Filter/Intval.php', | ||
'haanga_extension_filter_translation' => '/Extension/Filter/Translation.php', | ||
'haanga_extension_filter_trans' => '/Extension/Filter/Trans.php', | ||
'haanga_extension_filter_stringformat' => '/Extension/Filter/Stringformat.php', | ||
'haanga_extension_filter_capfirst' => '/Extension/Filter/Capfirst.php', | ||
'haanga_extension_filter_reverse' => '/Extension/Filter/Reverse.php', | ||
'haanga_extension_filter_substr' => '/Extension/Filter/Substr.php', | ||
'haanga_extension_filter_upper' => '/Extension/Filter/Upper.php', | ||
'haanga_extension_filter_isarray' => '/Extension/Filter/Isarray.php', | ||
'haanga_extension_filter_empty' => '/Extension/Filter/Empty.php', | ||
'haanga_extension_filter_trim' => '/Extension/Filter/Trim.php', | ||
'haanga_extension_filter_hostname' => '/Extension/Filter/Hostname.php', | ||
'haanga_extension_filter_count' => '/Extension/Filter/Count.php', | ||
'haanga_extension_filter_truncatewords' => '/Extension/Filter/Truncatewords.php', | ||
'haanga_extension_filter_dictsort' => '/Extension/Filter/Dictsort.php', | ||
'haanga_extension_filter_exists' => '/Extension/Filter/Exists.php', | ||
'haanga_extension_filter_title' => '/Extension/Filter/Title.php', | ||
'haanga_extension_filter_cut' => '/Extension/Filter/Cut.php', | ||
'haanga_extension_filter_date' => '/Extension/Filter/Date.php', | ||
'haanga_extension_filter_lower' => '/Extension/Filter/Lower.php', | ||
'haanga_extension_filter_slugify' => '/Extension/Filter/Slugify.php', | ||
'haanga_extension_filter_join' => '/Extension/Filter/Join.php', | ||
'haanga_extension_filter_escape' => '/Extension/Filter/Escape.php', | ||
'haanga_extension_filter_pluralize' => '/Extension/Filter/Pluralize.php', | ||
'haanga_extension_filter_safe' => '/Extension/Filter/Safe.php', | ||
'haanga_extension_filter_null' => '/Extension/Filter/Null.php', | ||
'haanga_extension_tag' => '/Extension/Tag.php', | ||
'hg_parser' => '/Compiler/Tokenizer.php', | ||
'haanga_compiler_parser' => '/Compiler/Parser.php', | ||
'haanga_compiler_tokenizer' => '/Compiler/Tokenizer.php', | ||
'haanga_yytoken' => '/Compiler/Parser.php', | ||
'haanga_yystackentry' => '/Compiler/Parser.php', | ||
'haanga_compiler_exception' => '/Compiler/Exception.php', | ||
'haanga_compiler_runtime' => '/Compiler/Runtime.php', | ||
'haanga_compiler' => '/Compiler.php', | ||
'haanga_exception' => '/Exception.php', | ||
'haanga_generator_php' => '/Generator/PHP.php', | ||
); | ||
// }}} | ||
|
||
// deps {{{ | ||
static $deps = array ( | ||
'haanga_extension_filter' => | ||
array ( | ||
0 => 'haanga_extension', | ||
), | ||
'haanga_extension_filter_translation' => | ||
array ( | ||
0 => 'haanga_extension_filter_trans', | ||
), | ||
'haanga_extension_tag' => | ||
array ( | ||
0 => 'haanga_extension', | ||
), | ||
'hg_parser' => | ||
array ( | ||
0 => 'haanga_compiler_parser', | ||
), | ||
'haanga_compiler_runtime' => | ||
array ( | ||
0 => 'haanga_compiler', | ||
), | ||
); | ||
// }}} | ||
|
||
$class = strtolower($class); | ||
if (isset($classes[$class])) { | ||
if (!empty($deps[$class])) { | ||
foreach ($deps[$class] as $zclass) { | ||
if (!class_exists($zclass, false) && !interface_exists($zclass, false)) { | ||
require __DIR__ . $classes[$zclass]; | ||
} | ||
} | ||
} | ||
|
||
if (!class_exists($class, false) && !interface_exists($class, false)) { | ||
require __DIR__ . $classes[$class]; | ||
} | ||
return true; | ||
} | ||
|
||
return false; | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
$data = array( | ||
'endsomething' => array('endbar' => 5), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ endsomething.endbar }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ foo }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
<?php echo php_uname();?> | ||
|
||
|
||
<?php echo php_uname();?> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
{% exec php_uname %} | ||
{% exec php_uname as foo %} | ||
{% include "assert_templates/exec-inc.tpl" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
hola | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
$data = array( | ||
'self' => array( | ||
'status' => true, | ||
'tiene_negativos' => true, | ||
'nsfw' => false, | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% if self.status == 'published' AND self.tiene_negativos AND !self.nsfw %} | ||
hola | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
$data = array('zfoo' => new stdclass, 'foo' => array()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{%if foo|isarray %} true {% endif %} | ||
{%if zfoo|isarray %} true {% endif %} |
Binary file renamed
BIN
+495 Bytes
...ates/locale/es_ES/LC_MESSAGES/messages.mo → ...mplates/locale/en/LC_MESSAGES/messages.mo
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
|
||
foo is null | ||
|
||
|
||
|
||
bar is not null | ||
|
||
|
||
|
||
foobar is not null | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
$data = array( | ||
'obj' => array( | ||
'foo' => NULL, | ||
'bar' => false, | ||
'foobar' => 0, | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% for k,val in obj %} | ||
{% if val|null %} | ||
{{ k }} is null | ||
{% else %} | ||
{{ k }} is not null | ||
{% endif %} | ||
{% endfor %} |
Oops, something went wrong.