1
|
1
|
new file mode 100644
|
...
|
...
|
@@ -0,0 +1,40 @@
|
|
0
|
+# Title: jsFiddle tag for Jekyll
|
|
1
|
+# Author: Brian Arnold (@brianarn)
|
|
2
|
+# Description:
|
|
3
|
+# Given a jsFiddle shortcode, outputs the jsFiddle iframe code.
|
|
4
|
+# Using 'default' will preserve defaults as specified by jsFiddle.
|
|
5
|
+#
|
|
6
|
+# Syntax: {% jsfiddle shorttag [tabs] [skin] [height] [width] %}
|
|
7
|
+#
|
|
8
|
+# Examples:
|
|
9
|
+#
|
|
10
|
+# Input: {% jsfiddle ccWP7 %}
|
|
11
|
+# Output: <iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/ccWP7/embedded/js,resources,html,css,result/light/"></iframe>
|
|
12
|
+#
|
|
13
|
+# Input: {% jsfiddle ccWP7 js,html,result %}
|
|
14
|
+# Output: <iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/ccWP7/embedded/js,html,result/light/"></iframe>
|
|
15
|
+#
|
|
16
|
+
|
|
17
|
+module Jekyll
|
|
18
|
+ class JsFiddle < Liquid::Tag
|
|
19
|
+ def initialize(tag_name, markup, tokens)
|
|
20
|
+ if /(?<fiddle>\w+)(?:\s+(?<sequence>[\w,]+))?(?:\s+(?<skin>\w+))?(?:\s+(?<height>\w+))?(?:\s+(?<width>\w+))?/ =~ markup
|
|
21
|
+ @fiddle = fiddle
|
|
22
|
+ @sequence = (sequence unless sequence == 'default') || 'js,resources,html,css,result'
|
|
23
|
+ @skin = (skin unless skin == 'default') || 'light'
|
|
24
|
+ @width = width || '100%'
|
|
25
|
+ @height = height || '300px'
|
|
26
|
+ end
|
|
27
|
+ end
|
|
28
|
+
|
|
29
|
+ def render(context)
|
|
30
|
+ if @fiddle
|
|
31
|
+ "<iframe style=\"width: #{@width}; height: #{@height}\" src=\"http://jsfiddle.net/#{@fiddle}/embedded/#{@sequence}/#{@skin}/\"></iframe>"
|
|
32
|
+ else
|
|
33
|
+ "Error processing input, expected syntax: {% jsfiddle shorttag [tabs] [skin] [height] [width] %}"
|
|
34
|
+ end
|
|
35
|
+ end
|
|
36
|
+ end
|
|
37
|
+end
|
|
38
|
+
|
|
39
|
+Liquid::Template.register_tag('jsfiddle', Jekyll::JsFiddle)
|
0
|
40
|
\ No newline at end of file
|