Listing available objects and properties in liquid templates

Is there a way to output (for debugging / informational purposes) available objects and object properties in a liquid template ?

That is, let's say I use the jekyll website generation tool, and I am in the index.html template (which, as far as I know, is a liquid template). It might look something like this.

 {% for post in site.posts %} <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li> {% endfor %} 

Is it possible to use template tags that could tell me / output in this template a variable called post (as well as other templates). Also, are there any template tags that I could use that would tell me that the post object has the keys date , title , url , excerpt , permalink , etc.

+4
source share
1 answer

There is no way to do this from the fluid template that I know of. I used the following bit of Ruby code to do this in a test for Jekyll, though ( setup_post is a helper method in the Jekyll test suite)

 post = setup_post("2008-11-21-complex.textile") classes = [] Liquid::Template.parse(post.content).root.nodelist.each do |token| classes << token.name if token.is_a?(Liquid::Variable) end 

It should be possible to write a Jekyll plugin that could display this material on your page based on the above code.

+1
source

Source: https://habr.com/ru/post/1498866/


All Articles