开发者

How to pass names of partials in Jekyll

I want to include a file, whose name is in page.var. How can I get get it included?

If the partial in page.var is written in markdown, how can I get it processed into html as it is included?

I've tried {% include {{page.var}} | markdownify %}, and every variation I can think of - and mostly I get n开发者_如何学运维o output and no error message.

I'm using the standard Jekyll - version 0.11.0.


According to the docs this is now possible:

The name of the file you wish to embed can be literal (as in the example above), or you can use a variable, using liquid-like variable syntax as in {% include {{my_variable}} %}. Note that unlike usual liquid variable syntax, you cannot have spaces inside the curly braces.


EDIT:

It's now possible thanks to the usage of {% include {{my_partial}} %}, as per alexpeller's response.

Old answer, before Jekyll allowed this:

You can't do that in Jekyll. The include directive expects a string; it doesn't "process" its argument. You can't even assign the filename to a regular liquid variable and include it. It has to be a string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜