Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: src/site/_plugins/code_sample.rb

Issue 11066080: Initial version of Dart web components article (Closed) Base URL: git@github.com:sigmundch/dartlang.org.git@master
Patch Set: moved generated code elsewhere Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1
2 module Jekyll
3
4 # This plugin renders a table with code and a running example side by side.
5 class CodeSampleTag < Liquid::Block
6
7 def initialize(tag_name, params, tokens)
8 super
9 @percent = params.strip
10 end
11
12 def render(context)
13 ("\n\n<table sytle='border:0px'><thead>" +
14 "<tr><td><strong>Sample source code</strong>" +
15 "</td><td>" +
16 "</td><td><strong>Sample running</strong></td></tr>" +
17 "</thead><tbody><tr>" +
18 "<td style='width:#{@percent}%;vertical-align:top;'>" + super.strip +
19 "</td><td style='width:100%;'>" +
20 "</td><td style='vertical-align:top;'>" +
21 "<iframe style='border:none;height:#{@height};width:#{@width};'" +
22 " src='#{@url}'></iframe>" +
23 "</td></tr></tbody></table>\n\n")
24 end
25
26 def unknown_tag(tag, params, tokens)
27 if tag == 'sample'
28 sample_params = params.split(' ')
29 @width = sample_params[0]
30 @height = sample_params[1]
31 @url = sample_params[2]
32 else
33 super
34 end
35 end
36
37 end
38 end
39
40 Liquid::Template.register_tag('codesample', Jekyll::CodeSampleTag)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698