-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add Layout XML Standard (new branch) #1078
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
layout: default | ||
group: coding-standards | ||
subgroup: Coding standards | ||
title: Layout XML Coding Standards | ||
menu_title: Layout XML Coding Standards | ||
menu_order: 100 | ||
contributor_name: SwiftOtter Studios | ||
contributor_link: https://swiftotter.com/ | ||
version: 2.1 | ||
github_link: coding-standards/xml-coding-standard.md | ||
--- | ||
|
||
# Layout XML Coding Standard | ||
|
||
### Name attribute | ||
|
||
The `name` attribute should adhere to the guidelines listed below. The `name` attribute should: | ||
|
||
- Be unique to the project. | ||
- Use a namespace approach where each child block's name contains its parent's name as well. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cons:
Pros:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding for the record (this is the salient point):
Because block names exist in the global layout scope, this isn't a "namespace approach"; rather, it's a hierarchy approach. |
||
- Have segments separated by a `.` (period). | ||
- Be all lowercase. | ||
- Never use `_` (underscores). | ||
|
||
*Example:* | ||
|
||
```xml | ||
<block name="header"> | ||
<block name="header.right"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Name" should not describe the position of a block. It should explain its purpose. We should add it as one of the rules. |
||
<block name="header.right.search"> | ||
<block name="header.right.search.autocomplete" /> | ||
</block> | ||
</block> | ||
</block> | ||
``` | ||
|
||
### As attribute | ||
|
||
The `as` attribute should follow the guidelines below. The value of `as`: | ||
|
||
- Only needs to be unique to the block that contains it. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @benmarks : With current implementation, this one can be confusing for block substitution scenario (when we add a block with same alias to substitute a other child) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have an internal goal of having this complete tonight (12-Jun), but it will be a couple more days. Thanks again for proposing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do we expect in this scenario? I'd leave the statement as is. |
||
- Should be as concise as possible, but with enough clarity to be understood within the block. | ||
- Can use an `_` (underscore) as a separator. | ||
- Should only be added if necessary. | ||
- Should be all lowercase. | ||
|
||
|
||
*Example:* | ||
|
||
```xml | ||
<block name="header"> | ||
<block name="header.right" as="right_actions"> | ||
<block name="header.right.search" as="search"> | ||
<block name="header.right.search.autocomplete" as="autocomplete" /> | ||
</block> | ||
</block> | ||
</block> | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can not be enforced without a more specific rule (add namespace?)