These are chat archives for jescalan/roots

Sep 2016
Anthony Nicholls
Sep 13 2016 09:55
ah ok is there a reason line 24 would not define this? I have a front matter variable that I can call with pos.tag and the content of that comes out fine in line 23 when the template compiles. pos.tag is what I am trying to split by tabs, and then wrap each in a span. Have tried creating a separate variable for pos.tag and then calling that and trying to split it too.
  • post.tag
Tom Kraak
Sep 13 2016 10:06
I assume there are multiple tags per post defined in the front matter?
think about why the error is mentioning length
Jeff Escalante
Sep 13 2016 15:11
yeah so the var declaration needs a single hyphen because its unbuffered code
the each does not
what you can do with jade to log things out and check them is this: != JSON.stringify(tags)
jade's syntax is very loose and ambiguous, often causes issues like this
Anthony Nicholls
Sep 13 2016 18:17
This message was deleted
Anthony Nicholls
Sep 13 2016 18:46

Thanks for your help guys, @jescalan tried this

span #{post.tags}
  -var tags = post.tags.split(',')
  each tag in tags
    span(class : 'tags') #{tags.tag}

but got the following: Cannot read property 'split' of null I get this output for post.tags if I stringify it "Zero Carbon, Zero Waste"
@tkraak when you said about length:

          -var a = post.tags
          -var b = JSON.stringify(cats)
          -var tags = b.split(',')
          -each tag in tags
            span #{tag}

It basically does what I want but outputs " on the first and last span element. I got this output ["\"Zero Carbon"," Zero Waste\""] with != JSON.stringify(tags)

Jeff Escalante
Sep 13 2016 18:47
So there's some incorrectly formatted data here
it seems?
well not
so the issue is that post.tags is coming up null
in at least one instance that file is compiled under
this file is a template for dynamic content, right?
is it ignored from being compiled normally?
Jeff Escalante
Sep 13 2016 18:52
if so, it probably doesn't have the variables you want, which may be why it comes up null
any templates used for plugins must be ignored from being compiled normally
Anthony Nicholls
Sep 13 2016 19:30
Yep was just that I had left the a few of the categories blank so they were returning null. Very simple :-). Thanks again for your help, and patience
Tom Kraak
Sep 13 2016 19:56
Jeff Escalante
Sep 13 2016 19:57
haha no problem, sorry it was so frustrating!
i know how that is
let us know when it's done so we can check out the result!
Anthony Nicholls
Sep 13 2016 22:08
Yep will do! Am building a website for my wife, as she is organising a sustainability week. I used to be a graphic designer but now run a pub. I did a bit of html and css and a few jquery plugins but never really written any javascript before but a good project to learn, and have always wanted to. Have now actually managed to write some stuff that I haven't just completely copied and pasted off the internet (with a fair bit of help from you) ;-)