Template Conditionals & Variables
-
@julian said:
Template variables are defined in a corresponding API call. For example, in this topic, the API call would be http://community.nodebb.org/api/topic/818
IF is simple boolean, although you can also use
<!-- IF @first -->
to display only in the first item of a list.Ah okay, cool! Thanks for the tip @julian
@baris I know right?
-
loggedIn
Awesome! What aboutloggedOut
?
Or does this mean if logged out aka guest...Thanks @baris !
Paging @psychobunny to read this topic . Could you list all template variables on the blog.nodebb? I'm sure this will help the designers.
-
What about loggedOut?
you can use
<!-- !loggedIn -->
Could you list all template variables on the blog.nodebb? I'm sure this will help the designers.
I think we should make a wiki of all API returns, that should help a lot. Something similar to this wiki article but for API returns.
Anything that comes from the page's API return is fair game in templates so for topic.tpl you would check this API call and then for anything in the root level you can do:
{topic_name}
To access values in objects:
{privileges.read}
And finally you can loop through arrays and create blocks like so:
<!-- BEGIN posts --> {posts.content} <!-- END posts -->
Maybe a templating guide in wiki would be useful as well.
-
@psychobunny The wiki would be invaluable.
-
I'm baffled as to how you managed to make Convoe so awesome without knowing this
-
@psychobunny Whoops I edited it, but yeah, I really didn't know this. Like I said before, I just take wild guesses lol.
-
Alright guide coming up pronto
-
-
Woooooooo! Nice @psychobunny Thanks!