In jekyll, the tag include can be used to include a parameterized template file. These parameters, however, are constrained to being supplied inline and constant, hence no captured text blocks can be passed. The custom tag rawinclude (see code below) allows for the instantiation of template files using the standard include parameters, but also passes a whole text block (without rendering liquid code in between) to the template file. Additionally, the block content is also passed as URI data encoded string which further allows for client-side download links for e.g. code snippets.
In the following example, rawinclude is exploited to pass the given python code to a template called sourcefile which, in turn, highlights the syntax and provides a download link for the raw code.
The implementation is largely based on raw.rb to read the content in between without modification. After that necessary encoding and escaping of the passed arguments takes place and finally include is used with the block contents wrapped into in-line parameters.
As include disallows ‘%}’ to be contained in the string, unliquidify is required to be run on the contents to restore the original format.