How to determine raw file's extension within template


#1

recently, I would like add toc within a html which was generated by asciidoctor. but most of the jekyll theme do not compatibale with asciidoctor. So I have to custom a template by my self:

within template, such as layout:post

{% if file.ext == "adoc" %}
	blah blah
{% elsif file.ext == "markdown" %}
	blah blah
{% endif %}

the file.ext variable doesn’t exist actually. so, here is the problem: how to determine the markup file’s extension?


#2

Jekyll has a page.path variable. You could use {% assign ext = page.path | split: "." | last %} to get the extension.


#3

thank you very much!