all repos — markup @ 9f38d4156f389f31b1741b85e3296191616ec23d

The code we use to render README.your_favorite_markup

add :eager option to markup
Charlie Somerville charlie@charliesomerville.com
Wed, 04 Dec 2013 10:24:16 +1100
commit

9f38d4156f389f31b1741b85e3296191616ec23d

parent

d565a88a743c2624351ce4cd1f027d2bb1cd76ed

1 files changed, 18 insertions(+), 10 deletions(-)

jump to
M lib/github/markup.rblib/github/markup.rb

@@ -27,20 +27,28 @@ content

end end - def markup(file, pattern, &block) + def markup(file, pattern, opts = {}, &block) loader = proc do - require file.to_s - add_markup(pattern, &block) + begin + require file.to_s + add_markup(pattern, &block) + true + rescue LoadError + false + end end - @@deferred_markups << loader - add_markup pattern do |*args| - @@deferred_markups.delete(loader) + + if opts[:eager] loader.call - block.call(*args) + else + @@deferred_markups << loader + add_markup pattern do |*args| + @@deferred_markups.delete(loader) + loader.call + block.call(*args) + end + true end - true - rescue LoadError - false end def command(command, regexp, &block)