Sorry. My bad. I should have said: “then the “other stuff” always gets displayed, no matter how FEW pages there are”
Seems like this should be working then, so I’ll have another look at it when I get back to the project. Just wanted to check I’d not cocked up the syntax, before beginning to apply forehead to wall.
Yep. Hugo Static Site Generator v0.15 BuildDate: 2015-11-25T14:34:54Z
Ah! –I’ve just realised where I was going wrong. Now I see why you two were asking if I was sure I meant lt rather than gt.
Misunderstanding of the syntax.
I was reading {{if lt 5 (len .Site.Pages)}} as meaning If (len .Site.Pages) is less than 5 but, of course it’s if 5 is less than (len .Site.Pages) –hence why I was getting the opposite result to what I wanted. Looks like whoever designed Golang’s template syntax was a fan of Polish Notation
[If anyone needs me, I’ll be over here in the corner, keeping this dunce hat warm!]
@stiobhart I think the correction intepretation would be to take the lesser of the two values rather than m seeking to see if site pages length is less than 5. I’m kind of asking because I’m confused about this conditional logic as well…
Have a look at that link to Polish Notation I put in my previous post. This template syntax kind of makes sense if you’re aware of the existence of that kind of mathematical notation.
If you’re not [or are expecting something a bit more like what they beat into us during maths lessons in school] it does take some getting your head around.