GithubHelp home page GithubHelp logo

blitz's People

Contributors

alexeyrybak avatar dmitry-saprykin avatar fadimko avatar mcuelenaere avatar narkq avatar poison avatar tony2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blitz's Issues

{{ IF }} interprets true as false

When returning true from a function called from Blitz, it doesn't interpret it as true when evaluating it in an if-expression and it takes the else-branch as a result.

Demo code:

<?php
var_dump(php_uname('a'));
var_dump(phpversion());
var_dump((new ReflectionExtension('blitz'))->getVersion());

class View extends Blitz {
    function m() {
        return true;
    }
}

$T = new View();
$T->load("{{ IF m() }}TRUE{{ ELSE }}FALSE{{ END }}");
var_dump($T->parse());

Output:

string(128) "Darwin MBP-Maurus 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64"
string(6) "5.5.25"
string(6) "0.8.18"
string(5) "FALSE"

Array/hash literals syntax

Let's say you have url(<route>, array <params>) function for the URL generation. By now, you are not able to call it like

<a href="{{ url("user", {"login": user.login}) }}">{{ user.name }}</a>

It would be great to add array/hash literals syntax. I suggest to use JSON-like syntax, i.e. [1, 2, 3] for arrays and {"foo": "bar"} for hashes.

Issues with boolean operators

  1. Comparing a string with a null-variable is always true
  2. Using a string with a boolean (eg; IF var && (a == b)) doesn't work when intval(var) = 0 (even though it's a non-empty string like 'bananas')

php7.3.3 Segmentation fault

<?php
$tpl = new Blitz('');
$tpl->setGlobal([]);
echo $tpl->parse();

Segmentation fault

Segmentation fault in parse method after setGlobal with an empty array.

Seg fault 7.3+ setGlobals empty array

$ php test.php
Segmentation fault
$ cat test.php
<?php
$view = new Blitz();
$view->load("simple tpl {var}");
$view->setGlobals([]);

$ php -v
PHP 7.3.11-1~deb10u1 (cli) (built: Oct 26 2019 14:14:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies

blitz compiled from last master branch

found workaround :)

+    public function setGlobals($parameters) {
+        if (PHP_MAJOR_VERSION > 5 && empty($parameters)) {
+            // Empty $parameters causes crash in PHP 7+
+            return;
+        }
+        parent::setGlobals($parameters);
+    }

Windows binary 5.6

Any change to get binary for windows last time i spend almost 4 hours to prepare compiler etc

Windows realase

Hey,
is there any plan in the future for releasing the version for windows users to run blitz projects locally?

How to remove \n in tpl if a variable is empty?

With the following tpl:

{{ $first }}
{{ $middle }}
{{ $last }}

And the following php:

<?php
$infos = array('first' => 'Firstname', 'middle' => '', 'last' => 'LASTNAME');
$T = new Blitz('test.tpl');
$T->display($infos);

When I display the source code of the page:

Firstname

LASTNAME

When {{ $middle }} is empty, how can I remove the second line without update my tpl to this unreadable file:

{{ $first }}{{ $middle }}{{ $last }}

Any idea?
Thanks.

Problem with blocks in template that was included

Hello!
Early this construction worked in PHP5, but now when I tried to use it in PHP7 (blitz 0.10.5) or PHP8 (blitz 0.10.5) I had a problem.
I can't iterate block in template that was included by Template API method.
What am I doing incorrectly?

test_blitz.php:

$t = new \Blitz();
$t->load('Main template: <!--include("./test_blitz.html"); -->');
$t->block('block1');
$t->display();

test_blitz.html:

Second template
- <!-- BEGIN block1 -->block1<!-- END block1 -->

console:

# php -f ./test_blitz.php
Main template:
Second template
-

Change default open/close comments tags

With default open/close comments tags ('/*' and '*/') and setup blitz.enable_comments = 1 sometimes you might need to do something like this in a template:
accept="image/*"
But you have a SYNTAX ERROR error: unexpected TAG_CLOSE, and this is normal. Although somewhat unexpected. It might be nice to change the default comment tags to the same with spaces (ex: '/* ' and ' */') or focus on the documentation

При включении опции blitz.enable_comments = 1 и оставлении тегов комментариев по-умолчанию ('/*' and '*/') иногда можно столкнуться с такой ситуацией - шаблон, в котором есть что-то типа:
accept="image/*"
Получим SYNTAX ERROR error: unexpected TAG_CLOSE, это нормально ибо тег не закрыт, но несколько неожиданно. Возможно надо сделать другие теги комментариев по-умолчанию, например с пробелами после открывающего и перед закрывающим (я так и сделал через конфиг), ну или в документации обратить на это внимание. Типа если хотите php-like комментарии в шаблонах, то стоит заметить, что бывают такие вот случаи

make error php 8.1

Hello, on php 8.1 with php8 branch have make error

#make
/bin/bash /usr/src/blitz/libtool --mode=compile cc -I. -I/usr/src/blitz -I/usr/src/blitz/include -I/usr/src/blitz/main -I/usr/src/blitz -I/usr/include/php/20210902 -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext -I/usr/include/php/20210902/ext/date/lib  -DHAVE_CONFIG_H  -g -O2    -DZEND_COMPILE_DL_EXT=1 -c /usr/src/blitz/blitz.c -o blitz.lo  -MMD -MF blitz.dep -MT blitz.lo
libtool: compile:  cc -I. -I/usr/src/blitz -I/usr/src/blitz/include -I/usr/src/blitz/main -I/usr/src/blitz -I/usr/include/php/20210902 -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext -I/usr/include/php/20210902/ext/date/lib -DHAVE_CONFIG_H -g -O2 -DZEND_COMPILE_DL_EXT=1 -c /usr/src/blitz/blitz.c -MMD -MF blitz.dep -MT blitz.lo  -fPIC -DPIC -o .libs/blitz.o
In file included from /usr/include/php/20210902/main/php.h:418,
                 from /usr/src/blitz/blitz.c:30:
/usr/src/blitz/blitz.c: In function ‘blitz_read_with_stream’:
/usr/src/blitz/blitz.c:375:77: error: ‘IGNORE_URL_WIN’ undeclared (first use in this function); did you mean ‘IGNORE_URL’?
     stream = php_stream_open_wrapper(filename, "rb", IGNORE_PATH|IGNORE_URL|IGNORE_URL_WIN|REPORT_ERRORS, NULL);
                                                                             ^~~~~~~~~~~~~~
/usr/include/php/20210902/main/php_streams.h:584:107: note: in definition of macro ‘php_stream_open_wrapper’
 #define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), NULL STREAMS_CC)
                                                                                                           ^~~~~~~
/usr/src/blitz/blitz.c:375:77: note: each undeclared identifier is reported only once for each function it appears in
     stream = php_stream_open_wrapper(filename, "rb", IGNORE_PATH|IGNORE_URL|IGNORE_URL_WIN|REPORT_ERRORS, NULL);
                                                                             ^~~~~~~~~~~~~~
/usr/include/php/20210902/main/php_streams.h:584:107: note: in definition of macro ‘php_stream_open_wrapper’
 #define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), NULL STREAMS_CC)
                                                                                                           ^~~~~~~
make: *** [Makefile:201: blitz.lo] Error 1
php -v
PHP 8.1.2 (cli) (built: Jan 27 2022 12:20:56) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

PHP callbacks restrictions (was: About PHP callback)

PHP callback is great. But it has security problem when we are in shared environment where we offer users to create their own templates only without accessing PHP code.

Imagine how dangerous this code:
{{ php::exec("rm -rf /home") }}

It can be avoided by simply disabling PHP callback, but I think it is good idea to make new directive eg. blitz.allowed_php_functions and blitz.allowed_php_class

Segfault when variable is too long

When a variable is a path and it's too long, this results in a segfault

array( 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGH' => 'No crash' ) ); $t = new Blitz(); $t->load($tpl); $t->display($data); ?>

some tests are broken with 8.2* branch

PHP 8.2.8
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
double Blitz object initialization [tests/double_init.phpt]
errors and warnings: execution [tests/errors2.phpt]
$_ as current iterations [tests/magic_current_iterations.phpt]
user-defined methods [tests/method.phpt]
method call from inner include [tests/mfi.phpt]
returning non-strings from user methods [tests/return_non_string_php8.phpt]
set and get [tests/set_and_get.phpt]
{{ $hash.sub.key }} syntax [tests/var_path.phpt]
=====================================================================


=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   17
---------------------------------------------------------------------

Number of tests :  106               105
Tests skipped   :    1 (  0.9%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    8 (  7.5%) (  7.6%)
Tests passed    :   97 ( 91.5%) ( 92.4%)
---------------------------------------------------------------------
Time taken      :    1 seconds
=====================================================================

{{ date("Y") }} does not seem to work

Hi,

As far as I know you can execute native PHP functions with Blitz, right?
But for some reason {{ date("Y") }} just prints "Y". Known bug? What are the alternatives?

Cheers,
Wouter

expressions in short if version

Right now one can use only strings/numbers/variables as first operand in if (... , ... [, ..]), but as expressions work fine for {{ IF (...) }} ... {{ END }} - this should be great to add expressions in the short version as well.

UNLESS with old-style php_templates tags - parse errors

$ php -r '$B = new Blitz(); $B->load("{{ IF AAA }}AAA{{ END }}");'
$ php -r '$B = new Blitz(); $B->load("AAA");'
Warning: blitz::load(): SYNTAX ERROR: end with no begin (noname_loaded_from_zval: line 1, pos 19) in Command line code on line 1

Issue with complex conditions and empty array/objects

{{IF array && boolean }}
Array and boolean
{{ELSE}}
Not array or not boolean
{{END}}

$T->display(
    array(
        'array' => array('a' => 'b'),
        'boolean' => true,
    )
);

Displays 'Not array or not boolean' instead of 'Array and boolean'. There's something wrong with casting objects and arrays to boolean expressions.

Assertion failed with php 7.2 in debug mode

Summary

blitz fails on assertion when php 7.2 is compliled in debug mode.

php versions tested

  • 7.2.16 - reproduced
  • 7.2.17 - reproduced
  • 7.1.28 - NOT reproduced

Operating systems tested

  • debian stretch 64 (9.6) under virtual box (linux)
  • debian stretch 64 9.6 under WSL windows 10 (wow)

How to reproduce

  • configure and build php 7.2 sources with --enable-debug
wget https://www.php.net/distributions/php-7.2.17.tar.gz
tar -xzf php-7.2.17.tar.gz
cd php-7.2.17/
./configure --disable-all --enable-debug --prefix=/usr/local/php-7.2.17-debug
make
sudo make install
  • configure and build blitz (git hash: 2353a6b)
cd blitz
/usr/local/php-7.2.17-debug/bin/phpize
./configure --with-php-config=/usr/local/php-7.2.17-debug/bin/php-config
make
make test
  • results
Number of tests :  104               103
Tests skipped   :    1 (  1.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   60 ( 57.7%) ( 58.3%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :   43 ( 41.3%) ( 41.7%)
  • Fail reason in all tests
php: /home/vagrant/build/php-7.2.17/Zend/zend_hash.c:2052: zend_hash_internal_pointer_reset_ex: Assertion `(&ht->nInternalPointer != pos || (ht)->gc
.refcount == 1) || ((ht)->u.flags & (1<<6))' failed.

Example gdb trace

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6cf742a in __GI_abort () at abort.c:89
#2  0x00007ffff6ceee67 in __assert_fail_base (fmt=<optimized out>,
    assertion=assertion@entry=0x555555ad8180 "(&ht->nInternalPointer != pos || (ht)->gc.refcount == 1) || ((ht)->u.flags & (1<<6))",
    file=file@entry=0x555555ad7fa0 "/home/vagrant/build/php-7.2.17/Zend/zend_hash.c", line=line@entry=2052,
    function=function@entry=0x555555ad8680 <__PRETTY_FUNCTION__.9456> "zend_hash_internal_pointer_reset_ex") at assert.c:92
#3  0x00007ffff6ceef12 in __GI___assert_fail (
    assertion=0x555555ad8180 "(&ht->nInternalPointer != pos || (ht)->gc.refcount == 1) || ((ht)->u.flags & (1<<6))",
    file=0x555555ad7fa0 "/home/vagrant/build/php-7.2.17/Zend/zend_hash.c", line=2052,
    function=0x555555ad8680 <__PRETTY_FUNCTION__.9456> "zend_hash_internal_pointer_reset_ex") at assert.c:101
#4  0x00005555558e841d in zend_hash_internal_pointer_reset_ex (ht=0x7ffff6863420, pos=0x7ffff6863444)
    at /home/vagrant/build/php-7.2.17/Zend/zend_hash.c:2052
#5  0x00007ffff65f67b4 in blitz_merge_iterations_set (tpl=0x7ffff6882000, input_arr=0x7ffff681f1a0) at /home/vagrant/build/blitz/blitz.c:5063
#6  0x00007ffff65f8d0e in zif_blitz_set (execute_data=0x7ffff681f150, return_value=0x7fffffffa6f0) at /home/vagrant/build/blitz/blitz.c:5562
#7  0x0000555555930da5 in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER () at /home/vagrant/build/php-7.2.17/Zend/zend_vm_execute.h:907
#8  0x00005555559b0114 in execute_ex (ex=0x7ffff681f030) at /home/vagrant/build/php-7.2.17/Zend/zend_vm_execute.h:59765
#9  0x00005555559b54a5 in zend_execute (op_array=0x7ffff687e300, return_value=0x0) at /home/vagrant/build/php-7.2.17/Zend/zend_vm_execute.h:63776
#10 0x00005555558d1461 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/vagrant/build/php-7.2.17/Zend/zend.c:1498
#11 0x000055555584520b in php_execute_script (primary_file=0x7fffffffdd90) at /home/vagrant/build/php-7.2.17/main/main.c:2594
#12 0x00005555559b7d1d in do_cli (argc=60, argv=0x555555e2cab0) at /home/vagrant/build/php-7.2.17/sapi/cli/php_cli.c:1011
#13 0x00005555559b8c1a in main (argc=60, argv=0x555555e2cab0) at /home/vagrant/build/php-7.2.17/sapi/cli/php_cli.c:1403
Aborted

Scope context inside included templates not work?

Hello.

We used our template preprocessor before, which injected all the include recursively into the parent templates and everything worked. But, having decided to use pure Blitz, we ran into the following problem. Context scope not working inside included templates.

Tested in:
PHP 7.4.33, Blitz 0.10.5, blitz.scope_lookup_limit=8, blitz.enable_include=1
PHP 8.2.7, Blitz 0.10.5, blitz.scope_lookup_limit=8, blitz.enable_include=1

index.php

<?php

error_reporting(E_ERROR);
header('Content-Type: text/plain');

$template_plain     = 'films.tpl';
$template_include   = 'films_with_include.tpl';

$end_data   = [];
$end_data['films']  = [
    ['film' => 'Film One'],
    ['film' => 'Film Two'],
];
$end_data['country']   = 'Wonderland';
$end_data['years']     = ['year' => '2023'];
$end_data['cast']      = [
    ['name' => 'Jeff Bridges'],
    ['name' => 'John Goodman'],
    ['name' => 'Julianne Moore'],
    ['name' => 'Steve Buscemi'],
];

$T1 = new Blitz($template_plain);
echo $T1->parse($end_data);

$T2 = new Blitz($template_include);
echo $T2->parse($end_data);

Want country, years and cast inside each film in films, set blitz.scope_lookup_limit=8
With this plain template all works

$template_plain = 'films.tpl';

{{ BEGIN films }}
Film Name: {{ $film }}
Country: {{ $country }}
Years: {{ BEGIN years }}{{ $year }}{{ END }}
Cast: {{ BEGIN cast }}{{ UNLESS $_first }}, {{ END }}{{ $name }}{{ END }}

{{ END }}
-------------------------------------------------------------

and all work ok

Film Name: Film One
Country: Wonderland
Years: 2023
Cast: Jeff Bridges, John Goodman, Julianne Moore, Steve Buscemi

Film Name: Film Two
Country: Wonderland
Years: 2023
Cast: Jeff Bridges, John Goodman, Julianne Moore, Steve Buscemi

-------------------------------------------------------------

But if we want move some template part in include, scope in include looks as broken

$template_include = 'films_with_include.tpl';

{{ BEGIN films }}
Film Name: {{ $film }}
{{ include("film_include.tpl") }}

{{ END }}
-------------------------------------------------------------

and film_include.tpl

Country: {{ $country }}
Years: {{ BEGIN years }}{{ $year }}{{ END }}
Cast: {{ BEGIN cast }}{{ UNLESS $_first }}, {{ END }}{{ $name }}{{ END }}

Failed result

Film Name: Film One
Country: 
Years: 
Cast: 

Film Name: Film Two
Country: 
Years: 
Cast: 

-------------------------------------------------------------

Most likely, this could be solved with the block method (actualy NOT, tested after this issue), but I would not want extra data loops inside the code. Perhaps this can be forcibly solved by adding a new ini parameter that would change this behavior or force include templates into the parent template (in fact, it works for me with my template preprocessor, but I would like it to work natively in pure Blitz)

High memory peak consumption

Alexey, hello!

In our projects we use the Blitz template engine and we ran into an unexpectedly high memory consumption when using the parse() method:

$template =<<<'EOL'
Some {{ $text }} text
EOL;

$t = new Blitz();
$t->load($template);

Timer::start('debug', 'fetch');
$text = str_repeat('x', 1024 * 1024 * 22);
Timer::stop();

Timer::start('debug', 'parse');
$t->parse(array(
    'text' => $text
));
Timer::stop();

Timer::start('debug', 'replace');
$template = str_replace('{{ $text }}', $text, $template);
Timer::stop();

foreach (Timer::dump() as $timer) {
    echo $timer['namespace'] . '::' . $timer['operation'] . "\n";
    echo '  Time: ' . $timer['microtime_diff'] . "\n";
    echo '  Memory: ' . $timer['memory_start'] . ' -> ' . $timer['memory_stop'] . ' (' . $timer['memory_diff'] . ')' . "\n";
    echo '  Max Memory: ' . $timer['memory_peak_stop'] . "\n";
}

The above script produces the following results:

PHP 5.3

SUMMARY debug: 3 operation(s) using 90186504 bytes per 0.111985 seconds

------------------------------------------------------------------------------------------------
| Timer          | Memory Peak    | Memory Fixed   | Memory Usage   | Operation      | #             
------------------------------------------------------------------------------------------------
| 0.019335       | 24169864       | 24162376       | 23077440       | fetch          | 1             
| 0.056742       | 114349856      | 47233616       | 90186504       | parse          | 2             
| 0.035908       | 114349856      | 70303904       | 23069784       | replace        | 3    

PHP 5.6

SUMMARY debug: 3 operation(s) using 67118256 bytes per 0.092410 seconds

------------------------------------------------------------------------------------------------
| Timer          | Memory Peak    | Memory Fixed   | Memory Usage   | Operation      | #             
------------------------------------------------------------------------------------------------
| 0.017415       | 23545192       | 23537496       | 23077920       | fetch          | 1             
| 0.038294       | 90656888       | 23540272       | 67118256       | parse          | 2             
| 0.036701       | 90656888       | 46610512       | 23069872       | replace        | 3             

PHP 7.0

SUMMARY debug: 3 operation(s) using 90191360 bytes per 0.096717 seconds

------------------------------------------------------------------------------------------------
| Timer          | Memory Peak    | Memory Fixed   | Memory Usage   | Operation      | #             
------------------------------------------------------------------------------------------------
| 0.018029       | 23433792       | 23434144       | 23073552       | fetch          | 1             
| 0.063715       | 113625880      | 46508776       | 90191360       | parse          | 2             
| 0.014973       | 113625880      | 69582304       | 23073528       | replace        | 3            

We are concerned about peak memory consumption.

Out system configuration:

System | FreeBSD  9.0-RELEASE-p4 FreeBSD 9.0-RELEASE-p4
/usr/obj/usr/src/sys/KERNEL20121021740 amd64
-- | --
Build Date | Jul 22 2016 15:10:06
Configure Command | './configure'   '--prefix=/usr/local/php-7.0.9'  '--with-config-file-scan-dir=/usr/local/php-7.0.9/etc/php'  '--with-config-file-path=/usr/local/php-7.0.9/etc' '--with-layout=GNU'  '--with-fpm-user=www' '--with-fpm-group=www' '--program-prefix='  '--disable-all' '--disable-debug' '--disable-ipv6' '--enable-ctype'  '--enable-dom' '--enable-fileinfo' '--enable-filter' '--enable-fpm'  '--enable-hash' '--enable-json' '--enable-libxml' '--enable-mbstring'  '--enable-mysqlnd' '--enable-pcntl' '--enable-phar' '--enable-pdo'  '--enable-opcache' '--enable-session' '--enable-simplexml'  '--enable-soap' '--enable-tokenizer' '--enable-xml' '--enable-xmlreader'  '--enable-xmlwriter' '--enable-zip' '--with-bz2' '--with-curl'  '--with-freetype-dir' '--with-gd' '--with-iconv=/usr/local'  '--with-jpeg-dir' '--with-libxml-dir=/usr/local' '--with-mcrypt'  '--with-mhash' '--with-mysqli' '--with-openssl' '--with-pcre-regex'  '--with-pdo-mysql' '--with-pdo-sqlite' '--with-sqlite3'  '--with-zlib-dir=/usr' 'CFLAGS=-O2 '-pipe' '-fstack-protector'  '-fno-strict-aliasing'' 'CPP=cpp'
Server API | FPM/FastCGI
Virtual Directory Support | disabled
Configuration File (php.ini) Path | /usr/local/php-7.0.9/etc
Loaded Configuration File | /usr/local/php-7.0.9/etc/php.ini
Scan this dir for additional .ini files | /usr/local/php-7.0.9/etc/php
Additional .ini files parsed | /usr/local/php-7.0.9/etc/php/blitz.ini, /usr/local/php-7.0.9/etc/php/memcache.ini, /usr/local/php-7.0.9/etc/php/opcache.ini, /usr/local/php-7.0.9/etc/php/phpredis.ini, /usr/local/php-7.0.9/etc/php/pinba.ini
PHP API | 20151012
PHP Extension | 20151012
Zend Extension | 320151012
Zend Extension Build | API320151012,NTS
PHP Extension Build | API20151012,NTS
Debug Build | no
Thread Safety | disabled
Zend Signal Handling | disabled
Zend Memory Manager | enabled
Zend Multibyte Support | provided by mbstring
IPv6 Support | disabled
DTrace Support | disabled
Registered PHP Streams | https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports | tcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0
Registered Stream Filters | zlib.*,  bzip2.*, convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13,  string.toupper, string.tolower, string.strip_tags, convert.*, consumed,  dechunk

Blitz support | enabled
-- | --
Version | 0.10.3.1
-- | -- | --
blitz.auto_escape | 0 | 0
blitz.check_recursion | 1 | 1
blitz.comment_close | */ | */
blitz.comment_open | /* | /*
blitz.enable_alternative_tags | 0 | 1
blitz.enable_callbacks | 1 | 1
blitz.enable_comments | 0 | 0
blitz.enable_include | 1 | 1
blitz.enable_php_callbacks | 1 | 1
blitz.lower_case_method_names | 1 | 1
blitz.path | no value | no value
blitz.php_callbacks_first | 1 | 1
blitz.remove_spaces_around_context_tags | 1 | 1
blitz.scope_lookup_limit | 0 | 0
blitz.tag_close | }} | }}
blitz.tag_close_alt | --> | -->
blitz.tag_open | {{ | {{
blitz.tag_open_alt | <!-- | <!--
blitz.throw_exceptions | 0 | 0
blitz.var_prefix | $ | $
blitz.warn_context_duplicates | 0 | 0

P. S.
My apologies for "excellent" English

Make error, latest php8 branch

Debian 12
php -v
PHP 8.2.8 (cli) (built: Jul 16 2023 11:00:43) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.8, Copyright (c) Zend Technologies
with Zend OPcache v8.2.8, Copyright (c), by Zend Technologies
with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans

#git clone https://github.com/alexeyrybak/blitz -b php8
#cd ./blitz
#phpize
Configuring for:
PHP Api Version:         20220829
Zend Module Api No:      20220829
Zend Extension Api No:   420220829
**configure.ac:165: warning: The macro `AC_PROG_LIBTOOL' is obsolete.
configure.ac:165: You should run autoupdate.
build/libtool.m4:100: AC_PROG_LIBTOOL is expanded from...
configure.ac:165: the top level**

#./configure
#make 

got some errors

/usr/src/blitz/blitz_debug.c: In function 'blitz_dump_ht':
/usr/src/blitz/blitz_debug.c:8:40: warning: passing argument 2 of 'zend_hash_apply_with_arguments' from incompatible pointer type [-Wincompatible-pointer-types]
    8 |     zend_hash_apply_with_arguments(ht, dump_array_values, 1, depth + 1);
      |                                        ^~~~~~~~~~~~~~~~~
      |                                        |
      |                                        int (*)(void *, int,  __va_list_tag *, zend_hash_key *) {aka int (*)(void *, int,  __va_list_tag *, struct _zend_hash_key *)}
In file included from /usr/include/php/20220829/Zend/zend.h:33,
                 from /usr/include/php/20220829/main/php.h:31,
                 from /usr/src/blitz/blitz_debug.c:1:
/usr/include/php/20220829/Zend/zend_hash.h:156:79: note: expected 'apply_func_args_t' {aka 'int (*)(struct _zval_struct *, int,  __va_list_tag *, struct _zend_hash_key *)'} but argument is of type 'int (*)(void *, int,  __va_list_tag *, zend_hash_key *)' {aka 'int (*)(void *, int,  __va_list_tag *, struct _zend_hash_key *)'}
  156 | ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...);
      |                                                             ~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/src/blitz/blitz_debug.c: In function 'dump_value':
/usr/src/blitz/blitz_debug.c:15:56: warning: passing argument 2 of 'zend_hash_apply_with_arguments' from incompatible pointer type [-Wincompatible-pointer-types]
   15 |         zend_hash_apply_with_arguments(Z_ARRVAL_P(zv), dump_array_values, 1, depth + 1);
      |                                                        ^~~~~~~~~~~~~~~~~
      |                                                        |
      |                                                        int (*)(void *, int,  __va_list_tag *, zend_hash_key *) {aka int (*)(void *, int,  __va_list_tag *, struct _zend_hash_key *)}
/usr/include/php/20220829/Zend/zend_hash.h:156:79: note: expected 'apply_func_args_t' {aka 'int (*)(struct _zval_struct *, int,  __va_list_tag *, struct _zend_hash_key *)'} but argument is of type 'int (*)(void *, int,  __va_list_tag *, zend_hash_key *)' {aka 'int (*)(void *, int,  __va_list_tag *, struct _zend_hash_key *)'}
  156 | ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...);
      |                                                             ~~~~~~~~~~~~~~~~~~^~~~~~~~~~

Issue with OR operations

$T = new Blitz();
$T->load("{{IF a || b}}a or b{{ELSE}}NOT a or b{{END}}");
$T->display(['a' => true]);

Fails! It should return 'a or b' but returns 'NOT a or b'. Fixed in PR #29

Mac OS X Capitan (x64) Error on make

/bin/sh /Users/arthur/www/test_tmpl/blitz-master/libtool --mode=compile cc -I. -I/Users/arthur/www/test_tmpl/blitz-master -DPHP_ATOM_INC -I/Users/arthur/www/test_tmpl/blitz-master/include -I/Users/arthur/www/test_tmpl/blitz-master/main -I/Users/arthur/www/test_tmpl/blitz-master -I/usr/local/Cellar/php70/7.0.12_5/include/php -I/usr/local/Cellar/php70/7.0.12_5/include/php/main -I/usr/local/Cellar/php70/7.0.12_5/include/php/TSRM -I/usr/local/Cellar/php70/7.0.12_5/include/php/Zend -I/usr/local/Cellar/php70/7.0.12_5/include/php/ext -I/usr/local/Cellar/php70/7.0.12_5/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/arthur/www/test_tmpl/blitz-master/blitz.c -o blitz.lo
mkdir .libs
cc -I. -I/Users/arthur/www/test_tmpl/blitz-master -DPHP_ATOM_INC -I/Users/arthur/www/test_tmpl/blitz-master/include -I/Users/arthur/www/test_tmpl/blitz-master/main -I/Users/arthur/www/test_tmpl/blitz-master -I/usr/local/Cellar/php70/7.0.12_5/include/php -I/usr/local/Cellar/php70/7.0.12_5/include/php/main -I/usr/local/Cellar/php70/7.0.12_5/include/php/TSRM -I/usr/local/Cellar/php70/7.0.12_5/include/php/Zend -I/usr/local/Cellar/php70/7.0.12_5/include/php/ext -I/usr/local/Cellar/php70/7.0.12_5/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/arthur/www/test_tmpl/blitz-master/blitz.c -fno-common -DPIC -o .libs/blitz.o
/Users/arthur/www/test_tmpl/blitz-master/blitz.c:45:10: fatal error: 'ext/standard/php_smart_str.h' file not found
#include "ext/standard/php_smart_str.h"
^
1 error generated.
make: *** [blitz.lo] Error 1

some if statements not working

tried a few ways and not working

displayall = 0 || 1
company_inventory_link = string or empty

not working

{{ IF \$company_inventory_link != '' }}
{{ IF \$company_inventory_link != '' && displayall}}
{{ IF company_inventory_link != '' && displayall}}
{{ IF company_inventory_link && displayall}}

works

{{ IF company_inventory_link != '' }}
{{ IF displayall }}

Create git tags when new releasing new versions

You're not creating git tags when releasing new versions, this makes it hard to look for the specific commit pertaining releases + having a git tag/github release makes homebrew updates easier.

Expressions in external functions

In #22 expressions inside if feature was implemented. What about external functions?

Now

{{my_custom_func(var == "foo")}}

ends with SYNTAX ERROR: invalid method call.

(v 0.10.2 if it matters)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.