[英]ISML conditional CSS class declaration
I'm new to SFCC and I was wondering what is the best practices with writing conditional CSS classes in the ISML template.我是 SFCC 的新手,我想知道在 ISML 模板中编写条件 CSS 类的最佳实践是什么。 I couldn't find anything in the documentation specifically for element parameters but I have seen some code which works but doesn't look right to me.
我在文档中找不到专门针对元素参数的任何内容,但我看到了一些有效但对我来说不合适的代码。
<div class="foo <isif condition="${bar}">baz</isif>"></div>
Is this the right way to conditionally add a CSS class?这是有条件地添加 CSS class 的正确方法吗?
This is the documentation I've found for isif https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FScriptProgramming%2FDemandwareJavaScriptExpressionsinISML.html This is the documentation I've found for isif https://documentation.b2c.commercecloud.salesforce.com/DOC1/index.jsp?topic=%2Fcom.demandware.dochelp%2FScriptProgramming%2FDemandwareJavaScriptExpressionsinISML.html
This variant is a little bit shorter这个变种有点短
<div class="foo ${bar ? 'baz' : 'someting else'}></div>
From my understanding you first need to write the isml condition and inside it the html div, something like this:据我了解,您首先需要编写 isml 条件,并在其中编写 html div,如下所示:
<isif condition="${bar}">
<div class="foo">baz</div>
</isif>">
I'm only a couple months new to SFF so forgive me if I'm wrong.我才刚接触 SFF 几个月,如果我错了,请原谅我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.