Talesoft / tale-jade

A complete and fully-functional implementation of the Jade template language for PHP
http://jade.talesoft.codes
MIT License
88 stars 10 forks source link

Duplicate mixins cause exception #99

Closed jaydenseric closed 8 years ago

jaydenseric commented 8 years ago

With the renderer configured to handle duplicate mixin declarations:

$renderer = new Tale\Jade\Renderer([
  'compiler_options' => [
    'replace_mixins' => true
  ]
]);

This is fine:

mixin test
  block

+test
  p Testing

But this causes an exception:

mixin test
  block

mixin test
  block

+test
  p Testing

Here is the trace:

Tale\Jade\Compiler\Exception: Failed to compile Jade: No handler compileMixin found for mixin found (mixin at 1:10) [components/app/template.jade] in /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Compiler.php:2286 Stack trace: #0 /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Compiler.php(898): Tale\Jade\Compiler->throwException('No handler comp...', Object(Tale\Jade\Parser\Node)) #1 /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Compiler.php(1885): Tale\Jade\Compiler->compileNode(Object(Tale\Jade\Parser\Node)) #2 /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Compiler.php(933): Tale\Jade\Compiler->compileChildren(Array, false) #3 [internal function]: Tale\Jade\Compiler->compileDocument(Object(Tale\Jade\Parser\Node)) #4 /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Compiler.php(920): call_user_func(Array, Object(Tale\Jade\Parser\Node)) #5 /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Compiler.php(479): Tale\Jade\Compiler->compileNode(Object(Tale\Jade\Parser\Node)) #6 /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Compiler.php(542): Tale\Jade\Compiler->compile('mixin test\n bl...', 'components/app/...') #7 /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Renderer.php(316): Tale\Jade\Compiler->compileFile('components/app/...') #8 /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Renderer/Adapter/File.php(173): Tale\Jade\Renderer->compileFile('components/app/...') #9 /Users/jaydenseric/Sites/ASU0124/vendor/talesoft/tale-jade/Renderer.php(340): Tale\Jade\Renderer\Adapter\File->render('components/app/...', Array) #10 /Users/jaydenseric/Sites/ASU0124/public/index.php(77): Tale\Jade\Renderer->render('components/app/...', Array) #11 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Array) #12 /Users/jaydenseric/Sites/ASU0124/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array) #13 /Users/jaydenseric/Sites/ASU0124/vendor/slim/slim/Slim/Route.php(325): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array) #14 /Users/jaydenseric/Sites/ASU0124/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(116): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response)) #15 /Users/jaydenseric/Sites/ASU0124/vendor/slim/slim/Slim/Route.php(297): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response)) #16 /Users/jaydenseric/Sites/ASU0124/vendor/slim/slim/Slim/App.php(443): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response)) #17 /Users/jaydenseric/Sites/ASU0124/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(116): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response)) #18 /Users/jaydenseric/Sites/ASU0124/vendor/slim/slim/Slim/App.php(337): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response)) #19 /Users/jaydenseric/Sites/ASU0124/vendor/slim/slim/Slim/App.php(298): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response)) #20 /Users/jaydenseric/Sites/ASU0124/public/index.php(84): Slim\App->run() #21 {main}
TorbenKoehn commented 8 years ago

Looking into that.

TorbenKoehn commented 8 years ago

Is this fixed for you now?

jaydenseric commented 8 years ago

Sorry for not getting back to you sooner, a colleague has taken on the work I was using this project for and I have not had a chance to test all these fixes. I will get him to look at incorporating these recent updates and set Composer back to normal. No doubt we will be using Tale Jade more in the future.

TorbenKoehn commented 8 years ago

No problem man, if any further problems arrive, keep this thread updated or create a new issue :)

Thanks for sticking to Tale Jade