Closed YamiOdymel closed 8 years ago
Yep, that looks pretty messy.
I could put that $__ignore stuff in an own, global variable but then i'd pollute the global scope again :(
But maybe I can put that in some kind of freeze_scope
compiler function, I'll think about it :)
I just want to leave a note, I didn't forget this.
I looked into this and it's actually a real problem. I can decide if I want to make the ignored variables configurable and have it messy or have them static and have it clean.
I'm working on a solution, but it will take a while. It's not a bug, it's a cosmetic thing, so it's at the end of my to-do list :)
I adressed this in the latest patch. Can you pull *@dev and check if it produces less bloat?
I think I even reduced it to less than it has ever been. There's still more possible, working on it :)
Wow, great work! It's much shorter now.
mixin item(label)
=$label
+item('A')
+item('B')
+item('C')
+item('D')
+item('E')
+item('F')
Size: 1,566 byte
<?php $__mixins = [];?><?php $__mixins['item'] = function(array $__arguments, array $__scope) {$__defaults = ['label' => null];extract(array_replace($__scope, array_replace($__defaults, $__arguments)));?><?=htmlentities(isset($label) ? $label : '', \ENT_QUOTES, 'UTF-8')?><?php };?><?php $__scope = \Tale\Jade\Compiler\create_scope(get_defined_vars()); $__mixinCallArgs = ['label' => 'A'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope); unset($__scope); unset($__mixinCallArgs); ?><?php $__scope = \Tale\Jade\Compiler\create_scope(get_defined_vars()); $__mixinCallArgs = ['label' => 'B'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope); unset($__scope); unset($__mixinCallArgs); ?><?php $__scope = \Tale\Jade\Compiler\create_scope(get_defined_vars()); $__mixinCallArgs = ['label' => 'C'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope); unset($__scope); unset($__mixinCallArgs); ?><?php $__scope = \Tale\Jade\Compiler\create_scope(get_defined_vars()); $__mixinCallArgs = ['label' => 'D'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope); unset($__scope); unset($__mixinCallArgs); ?><?php $__scope = \Tale\Jade\Compiler\create_scope(get_defined_vars()); $__mixinCallArgs = ['label' => 'E'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope); unset($__scope); unset($__mixinCallArgs); ?><?php $__scope = \Tale\Jade\Compiler\create_scope(get_defined_vars()); $__mixinCallArgs = ['label' => 'F'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope); unset($__scope); unset($__mixinCallArgs); ?>
Size: 3,828 byte
<?php $__mixins = [];?><?php $__mixins['item'] = function(array $__arguments, array $__scope) {$__defaults = ['label' => null];extract(array_replace($__scope, array_replace($__defaults, $__arguments)));?><?=htmlentities(isset($label) ? $label : '', \ENT_QUOTES, 'UTF-8')?><?php };?><?php $__ignore = array_flip([0 => 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['label' => 'A'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?><?php $__ignore = array_flip([0 => 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['label' => 'B'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?><?php $__ignore = array_flip([0 => 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['label' => 'C'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?><?php $__ignore = array_flip([0 => 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['label' => 'D'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?><?php $__ignore = array_flip([0 => 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['label' => 'E'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?><?php $__ignore = array_flip([0 => 'GLOBALS', 1 => '_SERVER', 2 => '_GET', 3 => '_POST', 4 => '_FILES', 5 => '_REQUEST', 6 => '_SESSION', 7 => '_ENV', 8 => '_COOKIE', 9 => 'php_errormsg', 10 => 'HTTP_RAW_POST_DATA', 11 => 'http_response_header', 12 => 'argc', 13 => 'argv', 14 => '__scope', 15 => '__arguments', 16 => '__ignore', 17 => '__block']);$__scope = array_diff_key(array_replace(get_defined_vars(), $__ignore), $__ignore); $__mixinCallArgs = ['label' => 'F'];call_user_func($__mixins['item'], $__mixinCallArgs, $__scope);unset($__ignore);unset($__scope);unset($__mixinCallArgs);?>
Awesome!
Thank you for testing :)
tale-jade installed via composer today,
and here's the jade file
output
Is it normal? Because if I use more and more mixins, it will be a disaster ..
I tried it on the demo site (http://sandbox.jade.talesoft.io/), it generated a normal code.