Skip to content

Commit

Permalink
add :eager option to markup
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Somerville committed Dec 3, 2013
1 parent d565a88 commit 9f38d41
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions lib/github/markup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,28 @@ def render(filename, content = nil)
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)
Expand Down

0 comments on commit 9f38d41

Please sign in to comment.