Index: src/site/_plugins/code_sample.rb |
diff --git a/src/site/_plugins/code_sample.rb b/src/site/_plugins/code_sample.rb |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dfbb7a7eae55cd22f03509920c6a179846773005 |
--- /dev/null |
+++ b/src/site/_plugins/code_sample.rb |
@@ -0,0 +1,40 @@ |
+ |
+module Jekyll |
+ |
+ # This plugin renders a table with code and a running example side by side. |
+ class CodeSampleTag < Liquid::Block |
+ |
+ def initialize(tag_name, params, tokens) |
+ super |
+ @percent = params.strip |
+ end |
+ |
+ def render(context) |
+ ("\n\n<table sytle='border:0px'><thead>" + |
+ "<tr><td><strong>Sample source code</strong>" + |
+ "</td><td>" + |
+ "</td><td><strong>Sample running</strong></td></tr>" + |
+ "</thead><tbody><tr>" + |
+ "<td style='width:#{@percent}%;vertical-align:top;'>" + super.strip + |
+ "</td><td style='width:100%;'>" + |
+ "</td><td style='vertical-align:top;'>" + |
+ "<iframe style='border:none;height:#{@height};width:#{@width};'" + |
+ " src='#{@url}'></iframe>" + |
+ "</td></tr></tbody></table>\n\n") |
+ end |
+ |
+ def unknown_tag(tag, params, tokens) |
+ if tag == 'sample' |
+ sample_params = params.split(' ') |
+ @width = sample_params[0] |
+ @height = sample_params[1] |
+ @url = sample_params[2] |
+ else |
+ super |
+ end |
+ end |
+ |
+ end |
+end |
+ |
+Liquid::Template.register_tag('codesample', Jekyll::CodeSampleTag) |