Skip to content

Loading…

Passing data from Converter into Liquid #2032

Closed
jashank opened this Issue · 1 comment

2 participants

@jashank

OK, this may be 100% evil, but here goes: what's the easiest way to get data from a page/post/whatever's Converter into Liquid variables that can be accessed from the page layout?

As an example, I've been working on Jekyll::Converters::Markdown::KramdownParser to make it give me a HTML table of contents that isn't in the document. I want to stuff that into a Liquid variable so I can say (for instance) {{ page.toc }} or something equally nice, and my table of contents drops into the layout, not necessarily with the rest of my {{ content }} (which is the only other approach I can find, and one I want to avoid at all costs).

Any suggestions for how to do this?

By the way, here's my code so far. To the best of my knowledge, it's the only converter of Kramdown::Converter::Toc to anything else in existence (also see this thread on kramdown-users).

Edit: this looks similar to, but is in fact the opposite of, #1509 and #1520; I want to get data the other way. The proposed fix doesn't help me much, though; I'm using data that's only available in a page's Converter.

@parkr parkr added the Question label
@parkr
Jekyll member

For this case, ideally, you'd have Nokogiri parse your HTML, list your headers, and output a UL or OL of your headers for you. I don't think converters and Liquid handle the same domain problem.

Jekyll 3's hook-based architecture should allow you to do this easily.

@parkr parkr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.