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.

KnockoutJS Template Customizations Need Documentation #746

@astorm

Description

@astorm

Magento 2 has made a number of customizations to the KnockoutJS framework that make it behave in ways that are different from standard KnockoutJS. These include (but are not limited to)

  1. Modifying the template system so it loads KnockoutJS templates from a URL (vs. the standard behavior of loading them from the page source)
  2. Parsing those templates for extra nodes and tags and attributes that are not a part of standard KnockoutJS

The end result is Magento 2 KnockoutJS template have custom tags and attributes whose behavior is completely undocumented. This makes it difficult for a third party developer to understand what the core system is doing, which makes difficult for a third party developer to follow along with the de-facto best practices in the Magento core modules.

For example, if you download the collection.html KnockoutJS template (an important template in Magento's UI Components), you end up with the following

<each args="data: elems, as: 'element'">
    <render if="hasTemplate()"/>
</each>

There are no <each/> or <render/> tags in HTML. KnockoutJS does not have an <each/> or <render/> tag. These tags are custom functionality Magento have built on top of KnockoutJS's template system. The above template corresponds (roughly? I'm barely keeping up here myself ;) ) to the following standard KnockoutJS

<!-- ko foreach: {data: elems, as: 'element'} -->
    <!-- ko if: hasTemplate() --><!-- ko template: getTemplate() --><!-- /ko --><!-- /ko -->
<!-- /ko -->

At minimum, the dev docs team should

  1. Document each custom tag/node (<each/>, <render/>, etc.)
  2. Document each custom attribute (args,if, etc.)
  3. Explain how Magento's custom KnockoutJS template engine transforms the above into standard KnockoutJS code

I don't have the above information (which is why I'm asking for it), so this will probably require an SME.

Metadata

Metadata

Assignees

Labels

Site ImprovementsUpdates to tools, processes, and site architecture that improve reader and contributor experienceTrackingCreated an internal Jira ticket to track work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions