How to write "if" instructions with PyroCMS Lex tags?

Here is my if statement in a loop. Sometimes a description will exist, and sometimes it will not. But all I get is the word LIKE , not ME when the description really exists.

 {{ description }} {{ if description }} ME {{ endif }} LIKE 
+4
source share
3 answers

Try the following:

 {if ('{pyro:page:is_home}' == TRUE)} ME > {else} LIKE {/if} 
0
source

If description can be evaluated to true , {{ if description }} may work.

But to check if the variable really exists (~ is not null), you can use the exists keyword, for example: {{ if exists description }} .

If you are not sure that description always exists, you should also put it in the "if" area, for example:

 {{ if exists description }} {{ description }} ME {{ endif }} LIKE 

Take a look at these documentation links:

0
source

It takes the space between the quotation in the "before" state, and it works.

  {{if description! = ''}}
       True
 {{endif}} 
0
source

Source: https://habr.com/ru/post/1486090/


All Articles