web-mode
web-mode copied to clipboard
indentation failure, and question about debugging web-mode
Hi, I have some php/html that doesn't indent correctly, and I can't figure out why. cc-mode has a variable called c-echo-syntactic-information-p
that is super helpful for debugging stuff like this, does web-mode have anything like that? I didn't see anything perusing the source.
Here's the php, cut down to a fairly minimal repro. You can see it starts to go wrong at the first function return and just keeps going...
This is with latest 17.0.4 on emacs 24.3.1 and 26.3, but it was also in v15 of web-mode.
Thanks, Chris
<?php
function newsletter_page_signup($atts, $content = null) {
ob_start();
?>
<div class="newsletter_signup"></div>
<?php
return ob_get_clean();
}
function newsletter_page_signup_span($atts, $content = null) {
ob_start();
?>
<span class="newsletter_signup"></span>
<?php
return ob_get_clean();
}
function newsletter_page_signup_modal($atts, $content = null) {
ob_start();
?>
<div class="newsletter_signup"></div>
<?php
return ob_get_clean();
}
Looks like a workaround is to put a fake ending function brace in each function. It screws up the return indentation still but that's not a huge deal for my use case.
Edit: Ah, but if you make it // } web-mode bug
then it breaks again. Hopefully that helps track it down. It looks like // web-mode bug }
works so the brace has to be the last character maybe.
Chris
<?php
function newsletter_page_signup($atts, $content = null) {
ob_start();
// }
?>
<div class="newsletter_signup"></div>
<?php
return ob_get_clean();
}
function newsletter_page_signup_span($atts, $content = null) {
ob_start();
// }
?>
<span class="newsletter_signup"></span>
<?php
return ob_get_clean();
}
function newsletter_page_signup_modal($atts, $content = null) {
ob_start();
// }
?>
<div class="newsletter_signup"></div>
<?php
return ob_get_clean();
}