Include snippets of text from external files into your markdown
Switch branches/tags
Nothing to show
Clone or download
Latest commit 2b3416f Dec 10, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/jekyll Bump to 0.1.3 Dec 10, 2018
spec Raise nicer error when `begin-snippet` missing Dec 10, 2018
.gitignore Initial commit Apr 14, 2018
.rspec Initial commit Apr 14, 2018
Gemfile Initial commit Apr 14, 2018
LICENSE.txt Initial commit Apr 14, 2018
README.md TODO in README Apr 24, 2018
jekyll-include-snippet.gemspec Add gem-release dev dep Apr 15, 2018

README.md

Jekyll::IncludeSnippet

Include snippets of text from external files into your markdown

Installation

Add it to your Gemfile (in a way that Jekyll will load):

source 'https://rubygems.org'

group :jekyll_plugins do
  gem 'jekyll-include_snippet'
end

Usage

Put the special "begin-snippet" and "end-snippet" comments into your source file:

# blah.rb

class Blah
  # begin-snippet: my_method_snippet
  def blah
    puts 'blah blah blah'
  end
  # end-snippet
end

Use it from your markdown:

---
title: "My Blerg Post"
date: "2018-01-01"
---

Blah blah here is some code:

```ruby
{% include_snippet my_method_snippet from path/to/blah.rb %}
```

Optionally, you can set a default source path in the YAML frontmatter:

---
title: "My Blerg Post"
date: "2018-01-01"
snippet_source: "path/to/blah.rb"
---

```ruby
{% include_snippet my_method_snippet %}
```

License

The gem is available as open source under the terms of the MIT License.

TODO

  • Could easily be optimised for better performance
  • Maybe a feature for evaluating code and including the result