How to make an if statement with JSONT

早过忘川 提交于 2019-12-13 01:25:18

问题


How can I check a property for a specific value??

IE: The JSONT version of

if(someProperty == someValue){
      //Do some stuff
}

回答1:


The control-of-flow syntax for if is:

{.if pagination}
// Do some stuff
{.end}

But if you're looking to do if/equals then:

{.equal? @index 1}
// Do some stuff
{.end}

That said, it appears that JSONT is a forked language without an active community working on any particular implementation so the syntax will vary. In this case, I'm referring to Squarespace's implementation.




回答2:


Ideally template should be free from such logic,Way to solve this problem is to break down the templates where one template to have the common stuff and many smaller ones which you need to apply only under certain condition, then have the condition in javascript code.



来源:https://stackoverflow.com/questions/22568931/how-to-make-an-if-statement-with-jsont

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