Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

Latest commit

 

History

History
31 lines (23 loc) · 1.98 KB

README.md

File metadata and controls

31 lines (23 loc) · 1.98 KB

jekyll-transclude

Update: I'd long since given up on trying to learn enough Ruby to try writing a plugin myself, but Hugo Manrique found a need for it and wrote a plugin.

A while back I created an issue in the official Jekyll repository to start a discussion around adding transclusion to the native include tag. The idea being that there are cases where you need to pass a block of formatted content to the included file, rather than just a simple string. While this is possible with capture blocks, this method relies on consistently using the same capture-include pattern in every instance, which seems prone to error.

I recommend reading through the issue thread but the feedback was essentially this: good idea for a new tag via plugin. Ok, great! Let's give it a shot:

  • Create a new transclude block tag.
  • This new tag will have the exact same functionality as include.
  • This new tag will allow a block of formatted content to be passed to the target file.
  • A new variable will be created to define a "transclusion slot" in the target file (e.g. transclude_content).

Proposed syntax:

{% transclude example.html %}
  <select>
    <option>Select...</option>
    <option>Alpha</option>
    <option>Bravo</option>
    <option>Charlie</option>
  </select>
{% endtransclude %}

Links