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

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: john's comments 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 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file.
4
5 module Jekyll
6
7 # This plugin renders a table with code and a running example side by side.
8 class CodeSampleTag < Liquid::Block
9
10 def initialize(tag_name, params, tokens)
11 super
12 @percent = params.strip
13 end
14
15 def render(context)
16 link = ""
17 if @src_url
18 link = "(<a href='#{@src_url}'>see complete source</a>)"
19 end
20
21 ("\n\n<table sytle='border:0px'><thead>" +
22 "<tr><td><strong>Sample source code #{link}</strong>" +
23 "</td><td>" +
24 "</td><td><strong>Sample running</strong></td></tr>" +
Kathy Walrath 2012/10/11 01:01:21 Sample running -> Running sample (or something el
Siggi Cherem (dart-lang) 2012/10/11 18:26:14 Interesting - thanks!
25 "</thead><tbody><tr>" +
26 "<td style='width:#{@percent}%;vertical-align:top;'>" + super.strip +
27 "</td><td style='width:100%;'>" +
28 "</td><td style='vertical-align:top;'>" +
29 "<iframe style='border:none;height:#{@height};width:#{@width};'" +
30 " src='#{@url}'></iframe>" +
31 "</td></tr></tbody></table>\n\n")
32 end
33
34 def unknown_tag(tag, params, tokens)
35 case tag
36 when 'sample'
37 @width, @height, @url = params.split(' ')
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