Is there a way to output (for debugging/informational purposes) the available objects and object properties in a liquid template ?
That is, say I'm using the jekyll site generation tool, and I'm in my index.html
template (which is, to my understanding, a liquid template). It might look something like this
{% for post in site.posts %}
<li><span>{{ post.date | date_to_string }}</span> » <a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
Are there any template tags I could use that would tell me/output a variable named post
was available in this template (as well as the other templates). Also, are there any template tags I could use that would tell me the post
object has the keys date
, title
, url
, excerpt
, permalink
, etc.
There's no way to do this from a Liquid template that I'm aware of. I used the following bit of Ruby code to do it in a test for Jekyll though ( setup_post
is a helper method in Jekyll's 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 output this stuff on your page based on the above code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.