mardi 27 février 2018

Handlebars: display different HTML tags using IF statements

The partial:

<ul><div>
    <h2></h2>
    
       <li>
           
       </li>
    
</ul></div>

The error:

Error: Unable to find closingIf after {"name":"openingIf","value":"@root.config.isMobile"}. (token: 31)
    at findClosingTokenInner (filename:3600:8)
    at findClosingToken (filename:3635:16)

After removing the tildes from the first and last lines -- same error.

After removing all tildes from the code -- same error.

After removing everything except the first and last lines -- new error:

Error: Unable to find closingTag after {"name":"openingTag","value":"ul"}. (token: 26)
    at findClosingTokenInner (filename:3600:8)
    at findClosingToken (filename:3635:16)

This works perfectly:


    <ul>
        <h2></h2>
        
           <li>
               
           </li>
        
    </ul>

    <div>
        <h2></h2>
        
           
        
    </div>


You can see how much longer this is now, and I am repeating almost all of the information. Is there no way to make the original code work with handlebars, or am I missing something (probably really simple...)?

Also, if you can explain why this problem is a thing, I will be eternally grateful.

Thank you!!!

Aucun commentaire:

Enregistrer un commentaire