julian
December 28, 2018, 3:41pm
1
Does anyone know what happens when you attempt to use the map filter on an array that’s empty? Say, for example, that you attempt:
site.pages | map: “path”
But site,pages doesn’t contain any pages. Will map return an empty array? Will it return false, or nil?
Why not try it and see? If you add the inspect
filter it should tell you.
{{ site.pages | map: “path” | inspect }}
julian
December 29, 2018, 11:47pm
3
That’s awesome. I had no idea that existed. Thanks.
Also, for things like this, Ruby’s irb
(interactive shell, aka ‘REPL’) is great. You can start it by typing irb
at the command line, then just run any Ruby command:
➜ ~ irb
2.5.3 :001 > [].map { |x| x.to_s }
=> []
julian
December 30, 2018, 7:50pm
5
Thanks, I’ll give that a shot as well. Does IRB recognize all of Liquid’s filters?