aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2018-07-23 14:15:52 +0200
committerMichał Górny <mgorny@gentoo.org>2018-07-23 14:15:52 +0200
commit5c7b54f8db7f29cf5b955ce9982ae1c3cef9a39a (patch)
tree1d76331eeced674a55c42cb0475542bba92dcd5b /_plugins
parentgleps: Handle disjoint source and destination filename cleaner (diff)
downloadwww-5c7b54f8db7f29cf5b955ce9982ae1c3cef9a39a.tar.gz
www-5c7b54f8db7f29cf5b955ce9982ae1c3cef9a39a.tar.bz2
www-5c7b54f8db7f29cf5b955ce9982ae1c3cef9a39a.zip
gleps: Transform .rst lazily
Diffstat (limited to '_plugins')
-rw-r--r--_plugins/gleps.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/_plugins/gleps.rb b/_plugins/gleps.rb
index 28e1fa7..85b1f82 100644
--- a/_plugins/gleps.rb
+++ b/_plugins/gleps.rb
@@ -21,6 +21,22 @@ module Gentoo
end
end
+ # based on http://greyblake.com/blog/2014/10/05/lazy-object-pattern-in-ruby/
+ class LazyRbST < ::BasicObject
+ def initialize(rst)
+ @rst = rst
+ end
+
+ def __target_object__
+ @__target_object__ ||= ::RbST.new(".. contents::\n..\n\n" + @rst).to_html(
+ 'initial-header-level' => 2)
+ end
+
+ def method_missing(method_name, *args, &block)
+ __target_object__.send(method_name, *args, &block)
+ end
+ end
+
class GLEPPage < Jekyll::Page
def initialize(site, name)
@site = site
@@ -49,12 +65,11 @@ module Gentoo
end
end
- @content = RbST.new(".. contents::\n..\n\n" + @content).to_html(
- 'initial-header-level' => 2)
-
site.data['gleps'] << data.merge({
'url' => data['permalink']
})
+
+ @content = LazyRbST.new(@content)
end
def output_ext