Skip to content

Support different control structure syntax for tpl.php files #32

@yorkshire-pudding

Description

@yorkshire-pudding

According to https://docs.backdropcms.org/php-standards#control-structures:

Alternate control statement syntax for templates
In templates, the alternate control statement syntax using colons instead of brackets is encouraged. Note that there should not be a space between the closing paren after the control keyword, and the colon, and HTML/PHP inside the control structure should be indented. For example:

<?php if (!empty($item)): ?>
  <?php print $item; ?>
<?php endif; ?>

<?php foreach ($items as $item): ?>
  <?php print $item; ?>
<?php endforeach; ?>

At the moment, these cause PHP errors and my desire to not have any PHPCS errors in my projects means I break this to get rid of the PHPCS errors.
I'm not sure why the above approach says there shouldn't be a space there as IMHO it is more readable with a space, but if it is feasible we could support this difference.

PS - I can't add types here but I would say this is a feature request rather than a bug as there is currently no current check for templates (interestingly - I did the PR to check for spaces in #14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions