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

replaceMixins option not working #96

Closed jaydenseric closed 8 years ago

jaydenseric commented 8 years ago

I have been attempting to get the replaceMixins option to work like so:

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

But I still get:

exception 'Tale\Jade\Compiler\Exception' with message 'Failed to compile Jade: Duplicate mixin name blockquote...

I have toggled the versions of the file on Github and have seen the options have been renamed from camel-case, but I have tried both to no success for the current version that installs via Composer.

Am I configuring it wrongly? I can't find documentation for configuration beyond the basics mentioned in the readme.

TorbenKoehn commented 8 years ago

The best source for the compiler options is probably the compiler constructor DocBlock (Sorry, haha). I'm open for any documentation help.

https://github.com/Talesoft/tale-jade/blob/master/Compiler.php#L210

You need to pass this as a compiler option (The compiler needs it, not the renderer)

You can do it like this:

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

I didn't forward all options, I'm thinking about a cooler config approach currently.

jaydenseric commented 8 years ago

Thanks, that works. I did eventually try that, but I had a separate error that threw me off. Thanks for the explanation!

jaydenseric commented 8 years ago

Can this be made true by default? Silently replacing duplicate mixins is how Pug works, it would be better for Tale Jade users to opt-out rather than opt-in.

TorbenKoehn commented 8 years ago

Well, I'm a great fan of stability and whenever I see things duplicated, my DRY-sensors activate and I assume it happened on accident.

I will think about this and keep this thread updated :)