Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Add XML Naming Convention to Code Standards #964

@bassplayer7

Description

@bassplayer7

There is currently no naming convention in place for layout XML files. This isn't really a syntax problem as there are few defined requirements on what you can and cannot do with the layout XML naming. However, I have noticed a pattern in various places in Magento and have found it to work very well in my own development. On Twitter,
I received one reply, @gazjoy, and they agreed with my sentiment as well.

My suggestion is to formalize the following XML naming convention (which I could submit a PR for if there is interest):

  • Attribute name: namespace approach, all lowercase, and separated by . (periods).
    • Example: parent.child.grandchild.descendant
    • Example header.actions.search
  • Attribute as: all lowercase, separated by _ (underscore), and concise because it is only scoped to the current block.
    • Example: search_box

While it is brief, I believe that it would be helpful to formalize and standardize on a best practice naming convention in those files. While much of Magento core appears to follow that approach, it certainly is not followed 100%. By baking this as a concrete best practice, it very well could help other developers in the same way that naming conventions such as BEM have helped front end web developers.

Feedback on page: /guides/v2.1/coding-standards/bk-coding-standards.html

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions