By Chris Gillis on
Can anyone tell me why most themes are using this:
<?php if ($page == 0): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
instead of this:
<?php if ($page == 0) { ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php } ?>
Is this just the third-party developer's personal preference, or is this style encouraged by the Drupal community?
Your thoughts...
-Chris
Comments
My guesses
It's probably just easier to read. At least for me, it's far easier while scanning for my eyes to pick out "endif" than to spot "}". Also, it may be a little easier to pick up on the meaning of it for some of the non-programmer users.
Drupal Coding Standards
In case anyone is interested, from: www.drupal.org/node/318
The technically optional
The technically optional refers to the equivalence of
The alternative block syntax is simply much easier to read in the tagsoup that are themes. Perhaps we can create a special theme section in the code style guidelines.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.
I was wondering the same
I was wondering the same thing myself. I can see the readability argument but an argument for using curly braces would be that editors like BBEdit can balance the braces and check if they're unmatched, which is a big advantage sometimes.
I tried to find any official guidance here on drupal.org, but this article was the closest I could get.