Is there a way to do more than one level of inheritance value overrides with dust.js?

女生的网名这么多〃 提交于 2019-12-03 16:13:11

Unfortunately it looks like this inheritance model isn't supported. Found this discussion on the linkedin fork: https://github.com/linkedin/dustjs/issues/101

That discussion referenced a particular passage in the docs:

... Inline partials never output content themselves, and are always global to the template in which they are defined, so the order of their definition has no significance. They are passed to all templates invoked by the template in which they are defined.

So I have two interpretations of this: one the order is non-deterministic and possibly based on how the templates are compiled. The second potential interpretation is that the global definition always supersedes for the template in which it's defined and any templates that template calls. If that's the correct interpretation then inline partials in parent templates will always 'win' if the block they're overriding is at that same level or higher in the inheritance hierarchy. That's the opposite of what I would expect and makes using inline partials for multi-level inheritance impossible (at least with the same named block).

Seems like this is a dead end, any other ideas on how this behavior could be accomplished in Dust?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!