Closed khc closed 9 years ago
This particular thing is hard-coded here and preferred on my environment. I think this should be an option, correct?
Yes, an option would be great. I'm using jade2php with WordPress and casting every object to array is troublesome, but accessing methods is impossible.
I am using with WordPress too, but with arrays (and some custom data model code) :)
Bumped version to 1.1.4. Added --no-arrays-only CLI option and arraysOnly: false option here. Please review and make me know it is what you requested :)
Something not right (or I'm doing something wrong)
git clone https://github.com/SE7ENSKY/jade2php.git
cd jade2php
npm update
echo '- var a = object.property' | bin/jade2php --no-arrays-only --omit-php-runtime --omit-php-extractor
And the result is:
<?php $a = $object['property'] ?>
My environment: OSX 10.9.4, node 0.10.35 (installed with brew)
Hey guys,
I've made some updates on js2php since the @ivankravchenko's fork. I suggest you to pull the changes if it doesn't break anything.
Thanks you, guys. @khc , that was my stupid code typo, fixed in 1.1.5 (5b9aa8d). @endel , switched to your original js2php implementation.
@endel , I suggest you check jsExpressionToPhp.coffee I've written this mess to handle some quirks. May be some of that work bring ideas on js2php improvements.
@khc , please let me know if current implementation is sufficient for you.
i still get the object[key] notation in my rendered php files..
Everything is working now:
echo '- var a = object.property' | jade2php --no-arrays-only --omit-php-runtime --omit-php-extractor
gives
<?php $a = $object->property ?>
There is a problem with compiling objects to PHP. The following Jade code:
is compiled to:
although I think the two last lines should look like:
jade2php depends on your library js2php where the code is generated properly. I've checked using the online demo.