-
Notifications
You must be signed in to change notification settings - Fork 1.7k
KnockoutJS Template Customizations Need Documentation #746
Description
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)
- Modifying the template system so it loads KnockoutJS templates from a URL (vs. the standard behavior of loading them from the page source)
- 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
- Document each custom tag/node (
<each/>
,<render/>
, etc.) - Document each custom attribute (
args
,if
, etc.) - 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.