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

Unified 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: remove css changes for now 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/site/articles/dart-web-components/index.markdown » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..79482409f2964de393f1fdb1a79527ce7ca46968
--- /dev/null
+++ b/src/site/_plugins/code_sample.rb
@@ -0,0 +1,48 @@
+# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+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)
+ link = ""
+ if @src_url
+ link = "(<a href='#{@src_url}'>see full source</a>)"
+ end
+
+ ("\n\n<table sytle='border:0px'><thead>" +
+ "<tr><td><strong>Source code #{link}</strong>" +
+ "</td><td>" +
+ "</td><td><strong>Try it out...</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)
+ case tag
+ when 'sample'
+ @width, @height, @url = params.split(' ')
+ when 'url'
+ @src_url = params
+ else
+ super
+ end
+ end
+
+ end
+end
+
+Liquid::Template.register_tag('codesample', Jekyll::CodeSampleTag)
« no previous file with comments | « no previous file | src/site/articles/dart-web-components/index.markdown » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698