我想更多地了解 HotTowel。
在 ~/App/views/shell.html 中,它包含:
<header>
<!--ko compose: {view: 'nav'} --><!--/ko-->
</header>
命令是否ko
嵌入在 Html 注释标签中?如果是这样,compose 命令做什么以及如何使用参数?
我想更多地了解 HotTowel。
在 ~/App/views/shell.html 中,它包含:
<header>
<!--ko compose: {view: 'nav'} --><!--/ko-->
</header>
命令是否ko
嵌入在 Html 注释标签中?如果是这样,compose 命令做什么以及如何使用参数?
Yes. This is a feature of KnockoutJS and it's called "virtual elements". The main advantage is that you don't have to add additional HTML tags if it's unnecessary. It's very useful and it's very clean in some scenarios. Mentioned in few places in Knockout documentation i.e.: http://knockoutjs.com/documentation/with-binding.html and http://knockoutjs.com/documentation/custom-bindings-for-virtual-elements.html
As of compose
it's a custom binding and is explained in HotTowel README:
The
compose
bindings for the header and footer are hard coded in Hot Towel to point to thenav
andfooter
views, respectively. The compose binding for the section#content
is bound to therouter
module's active item. In other words, when you click a navigation link its corresponding view is loaded in this area.