diff --git a/lib/Haanga/.travis.yml b/lib/Haanga/.travis.yml
new file mode 100644
index 0000000000000000000000000000000000000000..ed16720990e345c35fe2de9f904fb0a9de0e47f6
--- /dev/null
+++ b/lib/Haanga/.travis.yml
@@ -0,0 +1,15 @@
+language: php
+script: phpunit
+
+php:
+  - 5.3
+  - 5.4
+  - 5.5
+  - 5.6
+  - 7.0
+  - hhvm
+  
+before_script:
+  - curl -s http://getcomposer.org/installer | php
+  - php composer.phar install
+
diff --git a/lib/Haanga/composer.json b/lib/Haanga/composer.json
new file mode 100644
index 0000000000000000000000000000000000000000..3eec6ed7f0645018c6c316d60e40b278cc33a49b
--- /dev/null
+++ b/lib/Haanga/composer.json
@@ -0,0 +1,19 @@
+{
+    "name": "crodas/Haanga",
+    "description": "Template compiler for PHP, Django-style (as much as possible). Pretty efficent by avoiding to have anything at run-time.",
+    "version": "v1.0.7",
+    "authors": [
+        {
+            "name": "César D. Rodas",
+            "email": "crodas@php.net"
+        }
+    ],
+    "require": {
+
+    },
+    "autoload": {
+        "classmap": [
+            "lib/"
+        ]
+    }
+}
diff --git a/lib/Haanga/phpunit.xml b/lib/Haanga/phpunit.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ca09d1aa48a38dca2ef43d6b4b70f4a888f56fac
--- /dev/null
+++ b/lib/Haanga/phpunit.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
+<phpunit
+    backupGlobals               = "false"
+    backupStaticAttributes      = "false"
+    colors                      = "true"
+    convertErrorsToExceptions   = "true"
+    convertNoticesToExceptions  = "true"
+    convertWarningsToExceptions = "true"
+    processIsolation            = "false"
+    stopOnError                 = "true"
+    stopOnFailure               = "true"
+    stopOnIncomplete            = "true"
+    stopOnSkipped               = "ture"
+    syntaxCheck                 = "true"
+    strict                      = "false"
+    verbose                     = "true"
+    debug                       = "true"
+    bootstrap                   = "tests/bootstrap.php" >
+
+    <testsuites>
+        <testsuite name="Haanga tests">
+            <directory>tests/</directory>
+        </testsuite>
+    </testsuites>
+
+    <filter>
+        <whitelist>
+            <directory>tests/</directory>
+            <directory suffix=".php">lib/</directory>
+        </whitelist>
+    </filter>
+
+</phpunit>
diff --git a/lib/Haanga/tests/assert_templates/bitwise.tpl b/lib/Haanga/tests/assert_templates/bitwise.tpl
index bec9825289bdfce3aa6b3b5227c37d19dbccf4e9..d64ae12792236cdb6c28701dc98122e8c4833c8f 100644
--- a/lib/Haanga/tests/assert_templates/bitwise.tpl
+++ b/lib/Haanga/tests/assert_templates/bitwise.tpl
@@ -4,6 +4,6 @@
 {% if 13 & 2 == 0 %}
     Match
 {% endif %}
-{% if 15 | 8 == 15 %}
+{% if 15 || 8 == 15 %}
     Match
 {% endif %}
diff --git a/lib/Haanga/tests/assert_templates/bug24.html b/lib/Haanga/tests/assert_templates/bug24.html
new file mode 100644
index 0000000000000000000000000000000000000000..b3267050fec84b25d9d7a612c9f732b315de1088
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug24.html
@@ -0,0 +1,5 @@
+
+    a
+
+    b
+
diff --git a/lib/Haanga/tests/assert_templates/bug24.php b/lib/Haanga/tests/assert_templates/bug24.php
new file mode 100644
index 0000000000000000000000000000000000000000..c9ba9ea840afbfd42df0672f0ff9b28dea110aac
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug24.php
@@ -0,0 +1,7 @@
+<?php
+
+if (!class_exists('Obj', false)) {
+    require __DIR__ . '/bug25_class.php';
+}
+
+$data = array('obj' => new Obj);
diff --git a/lib/Haanga/tests/assert_templates/bug24.tpl b/lib/Haanga/tests/assert_templates/bug24.tpl
new file mode 100644
index 0000000000000000000000000000000000000000..4df0e17f9d89a430d6f3ef73bb63950ab2f8191f
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug24.tpl
@@ -0,0 +1,3 @@
+{% for a in obj.method %}
+    {{ a }}
+{% endfor %}
diff --git a/lib/Haanga/tests/assert_templates/bug25.html b/lib/Haanga/tests/assert_templates/bug25.html
new file mode 100644
index 0000000000000000000000000000000000000000..63494e843ee4698b48068d05354e306785b1bef9
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug25.html
@@ -0,0 +1,11 @@
+
+    a
+
+    
+
+    a
+
+    
+        test
+    
+
diff --git a/lib/Haanga/tests/assert_templates/bug25.php b/lib/Haanga/tests/assert_templates/bug25.php
new file mode 100644
index 0000000000000000000000000000000000000000..779f690ba214dc997deedce29833ad6e398d8d42
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug25.php
@@ -0,0 +1,7 @@
+<?php
+
+if (!class_exists('Obj', false)) {
+    require __DIR__ . '/bug25_class.php';
+}
+
+$data = array('obj' => new Obj, 'base' => array('endpoint' => 'a'));
diff --git a/lib/Haanga/tests/assert_templates/bug25.tpl b/lib/Haanga/tests/assert_templates/bug25.tpl
new file mode 100644
index 0000000000000000000000000000000000000000..06328b6f70b512b05e0520620133df7fde65e753
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug25.tpl
@@ -0,0 +1,7 @@
+{% for a in obj.endpoint %}
+    {{ base.endpoint }}
+
+    {% if forloop.last %}
+        test
+    {% endif %}
+{% endfor %}
diff --git a/lib/Haanga/tests/assert_templates/bug25_class.php b/lib/Haanga/tests/assert_templates/bug25_class.php
new file mode 100644
index 0000000000000000000000000000000000000000..df02a7d3cef537417a1cdf70726a40f5a579e1d2
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/bug25_class.php
@@ -0,0 +1,12 @@
+<?php
+
+class Obj 
+{
+    public function endpoint() {
+        return $this->method();
+    }
+
+    public function method(){
+        return array('a', 'b');
+    }
+}
diff --git a/lib/Haanga/tests/assert_templates/explode.html b/lib/Haanga/tests/assert_templates/explode.html
new file mode 100644
index 0000000000000000000000000000000000000000..29b55c5153a36984c195806ef653eb5de2dd446a
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/explode.html
@@ -0,0 +1,20 @@
+
+    1: f
+
+    1: o
+
+    1: o
+
+    1: ,
+
+    1: b
+
+    1: a
+
+    1: r
+
+
+    w: foo
+
+    w: bar
+
diff --git a/lib/Haanga/tests/assert_templates/explode.php b/lib/Haanga/tests/assert_templates/explode.php
new file mode 100644
index 0000000000000000000000000000000000000000..cefa262d8832bd09aff6fc885c9301e7e22f93f9
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/explode.php
@@ -0,0 +1,3 @@
+<?php
+
+$data  = array('text' => 'foo,bar');
diff --git a/lib/Haanga/tests/assert_templates/explode.tpl b/lib/Haanga/tests/assert_templates/explode.tpl
new file mode 100644
index 0000000000000000000000000000000000000000..b705b5f0369c85309094aea937bc3c7f52a9a4df
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/explode.tpl
@@ -0,0 +1,6 @@
+{% for w in text|explode %}
+    1: {{ w }}
+{% endfor %}
+{% for w in text|explode:"," %}
+    w: {{ w }}
+{% endfor %}
diff --git a/lib/Haanga/tests/assert_templates/filter.html b/lib/Haanga/tests/assert_templates/filter.html
index f1acc63ff9dcb36aa0f34426875c716f3747bd5b..be6f0a9ae890594eca83aecdca08f12942ee64da 100644
--- a/lib/Haanga/tests/assert_templates/filter.html
+++ b/lib/Haanga/tests/assert_templates/filter.html
@@ -1,7 +1,8 @@
-VALUE
-value
-vale
-5
+&quot;value&quot;
+&quot;VALUE&quot;
+&quot;value&quot;
+&quot;vale&quot;
+7
 DEFAULT VALUE
 
     HOLA QUE 
diff --git a/lib/Haanga/tests/assert_templates/filter.php b/lib/Haanga/tests/assert_templates/filter.php
index 9b9169fa644409c62a7059cd29b19ee1f978e38f..0721054dc088997e05682eef0710cdf1586ed31c 100644
--- a/lib/Haanga/tests/assert_templates/filter.php
+++ b/lib/Haanga/tests/assert_templates/filter.php
@@ -1,2 +1,2 @@
 <?php
-$data = array('var' => 'value');
+$data = array('var' => '"value"');
diff --git a/lib/Haanga/tests/assert_templates/filter.tpl b/lib/Haanga/tests/assert_templates/filter.tpl
index 9f8140450dcd6f7d42df08cd78aa19f10a26cc54..baacc2e0c28480a68651eef82ddbd50274b66677 100644
--- a/lib/Haanga/tests/assert_templates/filter.tpl
+++ b/lib/Haanga/tests/assert_templates/filter.tpl
@@ -1,3 +1,4 @@
+{{ var|default:"foobar" }}
 {{ var|upper }}
 {{ var|upper|lower }}
 {{ var|cut:"u" }}
diff --git a/lib/Haanga/tests/assert_templates/if_else_simple.tpl b/lib/Haanga/tests/assert_templates/if_else_simple.tpl
index aa25c0b799cb8b6c706e5eaa88fdb0d67955660d..b69333a8e87d5702e31ec49a0d303be4e89aa1a5 100644
--- a/lib/Haanga/tests/assert_templates/if_else_simple.tpl
+++ b/lib/Haanga/tests/assert_templates/if_else_simple.tpl
@@ -1,6 +1,6 @@
-{% if 1 == 2 ||  1+2 == 3 %}True{% else %}False{% endif %}
+{% if 1 == 2 OR  1+2 == 3 %}True{% else %}False{% endif %}
 {% if var|upper == var %}True{% else %}False{% endif %}
-{% if 1 === 2 ||  1+2 === 3 %}True{% else %}False{% endif %}
+{% if 1 === 2 OR  1+2 === 3 %}True{% else %}False{% endif %}
 {% if 1 !== 2 %}True{% else %}False{% endif %}
 {% if 1 > 2 %}True{% else %}False{% endif %}
 {% if 1 >= 2 %}True{% else %}False{% endif %}
diff --git a/lib/Haanga/tests/assert_templates/ifchanged.html b/lib/Haanga/tests/assert_templates/ifchanged.html
index 8988c82952f6ffef65dfb79999daf2a25d99acac..3a3c90657756df68ec68f02b0a69931a8c19ffe1 100644
--- a/lib/Haanga/tests/assert_templates/ifchanged.html
+++ b/lib/Haanga/tests/assert_templates/ifchanged.html
@@ -17,7 +17,7 @@
     Users with 22 years
     bar
 
-    continue
+    Users with 22 years
     foo
 
     Users with 23 years
diff --git a/lib/Haanga/tests/assert_templates/load.tpl b/lib/Haanga/tests/assert_templates/load.tpl
index 664fdc12df2708d052684d3f08152ad591c09d1e..1b77a885828d85056b1e5c7133326d0b4a1aadde 100644
--- a/lib/Haanga/tests/assert_templates/load.tpl
+++ b/lib/Haanga/tests/assert_templates/load.tpl
@@ -1,4 +1,4 @@
-{% load "../contrib/meneame_pagination.php" %}
+{% load "../../contrib/meneame_pagination.php" %}
 {% meneame_pagination page results_per_page total %}
 {% if mnm_prev %}
     <span class="nextprev">&#171; Previous</span>
diff --git a/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.mo b/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.mo
new file mode 100644
index 0000000000000000000000000000000000000000..a57cf97126f56a4e13a5b4aca29642d6389645ad
Binary files /dev/null and b/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.mo differ
diff --git a/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.po b/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.po
new file mode 100644
index 0000000000000000000000000000000000000000..06818db4bd1d7255577b9955142fda6da8dcc0de
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/locale/en/LC_MESSAGES/messages.po
@@ -0,0 +1,31 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-07-03 16:17+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: 
+msgid "hello"
+msgstr "hola"
+
+
+#: assert_templates/trans.tpl:1 assert_templates/trans.tpl:1
+msgid "Translation"
+msgstr "Traducción"
+
+#: assert_templates/trans.tpl:2 assert_templates/trans.tpl:2
+#, c-format
+msgid "Translation by %s"
+msgstr "Traducción por %s"
diff --git a/lib/Haanga/tests/assert_templates/method.html b/lib/Haanga/tests/assert_templates/method.html
index f2e3322a2bf6dccdc14d3ec7f25616c31c6bec8a..cf0aca4e31a72fe5d9b902056083c4b98af2350f 100644
--- a/lib/Haanga/tests/assert_templates/method.html
+++ b/lib/Haanga/tests/assert_templates/method.html
@@ -1,4 +1,6 @@
 foo
+foo
+FOO
 FOO
 bar
 BAR
diff --git a/lib/Haanga/tests/assert_templates/method.tpl b/lib/Haanga/tests/assert_templates/method.tpl
index b8f11730485cd90b017481de22f7a6cc4bbb4510..39054f77f6a896b6c9c91bdc203851f955b7b159 100644
--- a/lib/Haanga/tests/assert_templates/method.tpl
+++ b/lib/Haanga/tests/assert_templates/method.tpl
@@ -1,4 +1,6 @@
 {{ Object.method }}
+{{ Object.method() }}
 {{ Object.method|upper }}
+{{ Object.method()|upper }}
 {{ Object.bar }}
 {{ Object.bar|upper }}
diff --git a/lib/Haanga/tests/assert_templates/print_expr.html b/lib/Haanga/tests/assert_templates/print_expr.html
new file mode 100644
index 0000000000000000000000000000000000000000..13c11b896b141eebc9152e9e96c8ca014df5d1ac
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/print_expr.html
@@ -0,0 +1,4 @@
+hi I'm 5 !
+Hola
+hi I'm 5 !
+hi I'm 5 !
diff --git a/lib/Haanga/tests/assert_templates/print_expr.php b/lib/Haanga/tests/assert_templates/print_expr.php
new file mode 100644
index 0000000000000000000000000000000000000000..0f7acce40f1a0312a1346fecb6205a71b4beedd7
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/print_expr.php
@@ -0,0 +1,3 @@
+<?php
+
+$data = array('b' => 3);
diff --git a/lib/Haanga/tests/assert_templates/print_expr.tpl b/lib/Haanga/tests/assert_templates/print_expr.tpl
new file mode 100644
index 0000000000000000000000000000000000000000..f7afb9edca87330e089430e635d95b309851ef1d
--- /dev/null
+++ b/lib/Haanga/tests/assert_templates/print_expr.tpl
@@ -0,0 +1,4 @@
+hi I'm {{ 1+1+b }} !
+{{ "hola"|title}}
+hi I'm {{ 1+1+b|title }} !
+hi I'm {{ 1 > 2 ? 4 : 5 }} !
diff --git a/lib/Haanga/tests/assert_templates/trans.php b/lib/Haanga/tests/assert_templates/trans.php
index 0d95d2519d68b341b8062957260cb447f39e304c..3e7bd89fbc2033c99025a10dabb2020331d9d0a2 100644
--- a/lib/Haanga/tests/assert_templates/trans.php
+++ b/lib/Haanga/tests/assert_templates/trans.php
@@ -5,9 +5,11 @@ if (!is_callable('bindtextdomain')) {
     throw new Exception('no gettext enabled');
 }
 
-$locale='es_ES.UTF-8';
+$locale='en_US.utf8';
 putenv("LC_ALL=$locale");
-setlocale(LC_ALL, $locale);
+if (!setlocale(LC_ALL, $locale)) {
+    throw new Exception('no gettext enabled');
+}
 
-bindtextdomain("messages", dirname(__FILE__)."/locale");
+bindtextdomain("messages", dirname(__FILE__) . "/locale");
 textdomain("messages");
diff --git a/lib/Haanga/tests/bootstrap.php b/lib/Haanga/tests/bootstrap.php
new file mode 100644
index 0000000000000000000000000000000000000000..ab54a2a4d3bd988aa4ca50a1abc96117440236cf
--- /dev/null
+++ b/lib/Haanga/tests/bootstrap.php
@@ -0,0 +1,24 @@
+<?php
+
+require __DIR__ . '/../vendor/autoload.php';
+
+$config = array(
+    'cache_dir' => __DIR__ . '/tmp/',
+    'autoload' => true,
+    'template_dir' => __DIR__,
+    'debug' => TRUE,
+    'use_hash_filename' => FALSE,
+    'compiler' => array(
+        'allow_exec' => TRUE,
+        'global' => array('test_global', 'global1'),
+    )
+);
+
+Haanga::Configure($config);
+
+date_default_timezone_set('UTC');
+
+@mkdir(__DIR__ . "/tmp/");
+foreach (glob(__DIR__ . "/tmp/*/*") as $file) {
+    @unlink($file);
+}
diff --git a/lib/Haanga/tests/errorTest.php b/lib/Haanga/tests/errorTest.php
index 939ce7d4f3c3c0d4d5a35d19ee9074e1a3501e2f..e74e828d1971767c0c69ce7305d9c5d4f5681aa3 100644
--- a/lib/Haanga/tests/errorTest.php
+++ b/lib/Haanga/tests/errorTest.php
@@ -9,9 +9,8 @@ class errorTest extends PHPUnit_Framework_TestCase
      * @dataProvider tplProvider
      *  
      */
-    function testInvalidTemplates($tpl)
+    public function testInvalidTemplates($tpl)
     {
-        TestSuite::init();
         Haanga_Compiler::setOption('allow_exec', FALSE);
         try {
             Haanga::Load($tpl);
@@ -22,11 +21,11 @@ class errorTest extends PHPUnit_Framework_TestCase
         }
     }
 
-    public function tplProvider()
+    public static function tplProvider()
     {
         $datas = array();
-        foreach (glob("err_templates/*.tpl") as $err_file) {
-            $datas[] = array($err_file);
+        foreach (glob(__DIR__ . "/err_templates/*.tpl") as $err_file) {
+            $datas[] = array(substr($err_file, strlen(__DIR__)));
         }
 
         return $datas;
diff --git a/lib/Haanga/tests/templateTest.php b/lib/Haanga/tests/templateTest.php
index b6be7da57cea6fdffe51ca47c78a7540d4c606e6..af1fd16dd112e7b165156a37fd7bbbac0f33e793 100644
--- a/lib/Haanga/tests/templateTest.php
+++ b/lib/Haanga/tests/templateTest.php
@@ -25,19 +25,10 @@ class Foo_Bar {
  */
 class templateTest extends PHPUnit_Framework_TestCase
 {
-    public function testInit()
-    {
-        /* setup */
-        @mkdir("tmp/");
-        foreach (glob("tmp/*/*") as $file) {
-            @unlink($file);
-        }
-        TestSuite::init();
-    }
-
     public function init($test_file, &$expected)
     {
-        if ($test_file == 'assert_templates/strip_whitespace.tpl') {
+        Haanga_Compiler::setOption('allow_exec', true);
+        if ($test_file === '/assert_templates/strip_whitespace.tpl') {
             Haanga_Compiler::setOption('strip_whitespace', TRUE);
             $expected = rtrim($expected). ' '; /* weird output */
         } else {
@@ -52,6 +43,7 @@ class templateTest extends PHPUnit_Framework_TestCase
         $this->init($test_file, $expected);
         $output = Haanga::Load($test_file, $data, TRUE);
         $this->assertEquals($output, $expected);
+        $this->assertTrue(filemtime(__DIR__ . $test_file) <= filemtime(__DIR__ . '/tmp/assert_templates/' . basename($test_file) . '.php'));
     }
 
     /** 
@@ -59,8 +51,9 @@ class templateTest extends PHPUnit_Framework_TestCase
      */
     public function testLambda($test_file, $data, $expected)
     {
+        chdir(dirname(__DIR__ . '/' . $test_file));
         $this->init($test_file, $expected);
-        $callback = Haanga::compile(file_get_contents($test_file), $data);
+        $callback = Haanga::compile(file_get_contents(__DIR__ . $test_file), $data);
         $output   = $callback($data);
         $this->assertEquals($output, $expected);
     }
@@ -78,37 +71,14 @@ class templateTest extends PHPUnit_Framework_TestCase
         $this->assertFalse(Haanga::$has_compiled);
     }
 
-    /** 
-     * @dataProvider tplProvider 
-     * /
-    public function testCLICompiler($test_file, $data, $expected)
-    {
-        TestSuite::init();
-        $GLOBALS['argv'][1] = $test_file;
-        $GLOBALS['argv'][2] = '--notags';
-
-        ob_start();
-        Haanga_Compiler::main_cli();
-        $code = ob_get_clean();
-
-        eval($code);
-
-        $file     = basename($test_file);
-        $pos      = strpos($file,'.');
-        $function = substr($file, 0, $pos).'_template';
-        $output   = call_user_func($function, $data, TRUE);
-
-        $this->assertEquals($output, $expected);
-    }
-    /* */
-
-    public function tplProvider()
+    public static function tplProvider()
     {
         $datas = array();
-        foreach (glob("assert_templates/*.tpl") as $test_file) {
+        foreach (glob(__DIR__  . "/assert_templates/*.tpl") as $test_file) {
             $data = array();
             $data_file = substr($test_file, 0, -3)."php";
             $expected  = substr($test_file, 0, -3)."html";
+            $test_file = substr($test_file, strlen(__DIR__));
             if (!is_file($expected)) {
                 if (!is_file($expected.".php")) {
                     continue;