Closed jacmoe closed 8 years ago
Ideally, I would like to be able to just indent like this:
-$menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],'linkOptions' =>['data-method' => 'post']]
I am aware that it is not completely valid Jade - I think - but MtHaml allows this. It would make for tighter code.
Should probably also be fixed for unbuffered code?
= and !=
I will have a look into this!
The current engine actually parses the indentation of unbuffered code and strips it to keep the internal level updated to be able to break out of the code-block on outdentation.
You can use the following three styles right now:
unindented:
- $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'],'linkOptions' =>['data-method' => 'post']]
indented by one level only:
- $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],'linkOptions' =>['data-method' => 'post']]
indented on multiple levels:
- $menuItems[] = [
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' =>[
'data-method' => 'post'
]];
To get the last bracket indented correctly, you have to move down one level first
-
$menuItems[] = [
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' =>[
'data-method' => 'post'
]
];
I might ignore the indentation level here in a future version!
Yes, but now I have a clearer picture of what is wrong.
See the indentation? The relevant source code:
if (Yii::$app->user->isGuest)
-$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]
-$menuItems[] = ['label' => 'Login',
'url' => ['/site/login']]
else
-$menuItems[] = ['label' => 'Users', 'url' => ['/user/index']]
I have 'pretty' turned on. Perhaps I should test it without..
I'll test that right now and fix it, let me check.
Just for good measure:
-$menuItems[] = ['label' => 'Issues',
'url' => ['/issue/index']]
if (Yii::$app->user->isGuest)
-$menuItems[] = ['label' => 'Login',
'url' => ['/site/login']]
-$menuItems[] = ['label' => 'Users', 'url' => ['/user/index']]
else
-$menuItems[] = ['label' => 'Gii', 'url' => ['/gii']]
That code works
If you don't code block right before an else conditional, all is well. :)
EDIT: scrap that - the indentation is still wonky. Sorry about the noise. :)
I just updated Tale Jade and added smaller tests for conditionals, especially one handling your case specifically
It passes on all supported PHP versions https://travis-ci.org/Talesoft/tale-jade/builds/89463155
It's working fine with correct indentation. Make sure you always indent the same way and either one level up, one level down or stay on the same level.
Could you send me the complete file you used? That way I may take a look at it and check if we can avoid that problem in the future somehow.
Thanks for testing :)
Tell me if I can close this issue (or you might close it yourself)
I will close this issue and if it becomes a real problem I will see if I can make a minimal reproducible test case. Perhaps there is wonkiness either in my file or the implementation ( Yii 2 framework).
Thanks for making this library :)
closing
I get this error when I try to use block buffered code:
This kind of code can reproduce the error: