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

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: 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
Jennifer Messerly 2012/10/10 02:37:20 copyright header? (p.s. sorry I forgot to review
Siggi Cherem (dart-lang) 2012/10/10 17:20:55 Done.
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 link = ""
14 if @src_url != nil
Jennifer Messerly 2012/10/10 02:37:20 I think in Ruby, you'd typically write: if @src_u
Siggi Cherem (dart-lang) 2012/10/10 17:20:55 Done.
15 link = "(<a href='#{@src_url}'>see complete source</a>)"
16 end
17
18 ("\n\n<table sytle='border:0px'><thead>" +
Jennifer Messerly 2012/10/10 02:37:20 nit: you don't need the +, Ruby will concat adjace
Siggi Cherem (dart-lang) 2012/10/10 17:20:55 mmm.. this didn't work for me, the render method r
Jennifer Messerly 2012/10/10 17:48:03 doh, I guess you need to escape the end of line wi
19 "<tr><td><strong>Sample source code #{link}</strong>" +
20 "</td><td>" +
21 "</td><td><strong>Sample running</strong></td></tr>" +
22 "</thead><tbody><tr>" +
23 "<td style='width:#{@percent}%;vertical-align:top;'>" + super.strip +
24 "</td><td style='width:100%;'>" +
25 "</td><td style='vertical-align:top;'>" +
26 "<iframe style='border:none;height:#{@height};width:#{@width};'" +
27 " src='#{@url}'></iframe>" +
28 "</td></tr></tbody></table>\n\n")
29 end
30
31 def unknown_tag(tag, params, tokens)
32 case tag
33 when 'sample'
34 sample_params = params.split(' ')
Jennifer Messerly 2012/10/10 02:37:20 common to write this as: @width, @height, @url =
Siggi Cherem (dart-lang) 2012/10/10 17:20:55 cool. I'd really like to have this in dart...
35 @width = sample_params[0]
36 @height = sample_params[1]
37 @url = sample_params[2]
38 when 'url'
39 @src_url = params
40 else
41 super
42 end
43 end
44
45 end
46 end
47
48 Liquid::Template.register_tag('codesample', Jekyll::CodeSampleTag)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698