简体   繁体   中英

How to use params pass through template in Dustjs/Krakenjs

I'm still new in Kraken.js and Dust, so need some help in this.

For example, I'm including a partial template like below:

{> "modal/modalDialog" type="assign" /}

Then I have that template looks like below, which placed in some other folder, and I want to do conditional checking, if the type is "assign", I want to show some text, else, do something else. I tried using {@eq} like below, but its not working.

<div id="{type}" class="modal">
  {@eq key=type value="assign"}Assign this{/eq}
  {@eq key=type value="user"}Introduce us{/eq}
</div>

I know I can define the value in the JS model etc, but thinking there must be a way to do without the need to define in controller. Or

Offhand that looks correct. My guess is that you have managed to get two versions of dust loaded and the helpers have registered with one and you are using the other one. That would mean the eq helper is not being found and silently failing. You can confirm this by setting dust.debugLevel='WARN'.

If that is the problem, try explicitly using the 1.1.1 version of dustjs-helpers in your package.json. This all ought to be ironed out once a recent change to dustjs-helpers to make dust a peer dependency gets published.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM