Template parsing system help documents
-
I am working on a modification to public/templates/login.tpl that would change the button for an alternate login.
Using <!-- IF -->'s
I tried
<!-- IF {authentication.name} == steam --> STeAm <!-- ENDIF {authentication.name} == steam --> <!-- IF {authentication.name} !== steam --> <li class="{authentication.name}"><a rel="nofollow" href="{authentication.url}"><i class="fa fa-{authentication.icon}-square fa-3x"></i></a></li> <!-- ENDIF {authentication.name} !== steam -->
Which prints STeAm twice before both my alternate logins (one for steam, and one for google+). I have also tried
<!-- IF {authentication.name} == steam --> STeAm <!-- ELSE --> <li class="{authentication.name}"><a rel="nofollow" href="{authentication.url}"><i class="fa fa-{authentication.icon}-square fa-3x"></i></a></li> <!-- ENDIF {authentication.name} == steam -->
Which prints STeAm just once and doesn't print anything after ELSE.
Is there any documentation on the template system you are using I can review to better understand if statements in templates?
-
hey @cani we need to write a wiki page on the template system
it does not support logic in conditionals, I'm not sure if that's something we will decide to add or not in the near future
how you could go about doing this is something like so:
from API:
{ "steam": true }
in template:
<!-- IF steam --> this will be visible <!-- ENDIF steam -->
let me know if you run into any other problems
-
Added steam to api, just not sure why this isn't working
<!-- BEGIN authentication --> <!-- IF authentication.steam --> {authentication.steam} <!-- ENDIF authentication.steam --> <li class="{authentication.name}"><a rel="nofollow" href="{authentication.url}"><i class="fa fa-{authentication.icon}-square fa-3x"></i></a></li> <!-- END authentication -->
outputs
EDIT: even changing "IF authentication.steam" to "IF madeupvarofawesome" still outputs anything in it. Being a made up var shouldn't it be anything but true?
-
hey @cani, if the variable doesn't exist the block shouldn't show up. perhaps you can paste the full template and data from the API and I'll attempt to help you debug?
-
/nodebb/public/templates/login.tpl @ http://l4fd.info/login.tpl.txt
/nodebb/node_modules/nodebb-plugin-openid-steam/library.js @ http://l4fd.info/library.jsCan't figure out why {authentication.steam} returns false and <!-- IF authentication.steam --> still outputs anything in it.