jekyll_example_embed 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/jekyll_example_embed.rb +30 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 931fec50c13b3b12d361451ac22f5fc4f7d843d6
4
+ data.tar.gz: a4cdb381f1ea9274fc8ef4c5d35b345683220c5e
5
+ SHA512:
6
+ metadata.gz: 23ee7ec955c90093f263b893269e7d354de5efc23ea878a83136f464de9b5bd871c0a6777639d3d7a0cb01a036cd02c336b3dccf647ebcd2d01ba565a16ae301
7
+ data.tar.gz: 72bbbc8edfdb33f5d0866da6961fb3bcb4b1b48fb467ee7b80e7aeeffe241170e806ff6b6c92e9471baa74835b2c91a6c0b81934c026b0155f41f49d88cb4b72
@@ -0,0 +1,30 @@
1
+ module Jekyll
2
+ class ExampleEmbedTag < Liquid::Tag
3
+ def initialize(tag_name, text, tokens)
4
+ @example = text.strip
5
+ super
6
+ end
7
+
8
+ def render(context)
9
+ lang, name = @example.split('/')
10
+
11
+ document = context.registers[:site].collections['examples'].docs.detect do |document|
12
+ document.relative_path == "_examples/#{@example}"
13
+ end
14
+
15
+ if document.nil?
16
+ puts "** ERROR: Could not find example #{@example}\n"
17
+ return
18
+ end
19
+
20
+ highlight = context.stack do
21
+ wrapped_content = "{% highlight #{lang} %}#{document.content}{% endhighlight %}"
22
+ Liquid::Template.parse(wrapped_content).render!(context)
23
+ end
24
+
25
+ "<h4>#{name}</h4><h5>Source</h5>#{highlight}<h5>Result</h5><iframe src=\"#{document.url}\" frameBorder=\"0\"></iframe>"
26
+ end
27
+
28
+ Liquid::Template.register_tag('example_embed', Jekyll::ExampleEmbedTag)
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_example_embed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sonny Michaud
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: michaud.sonny@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/jekyll_example_embed.rb
20
+ homepage:
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.3
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Embed examples in Jekyll
44
+ test_files: []