lib/mastalk/extensions.rb in mastalk-0.2.1 vs lib/mastalk/extensions.rb in mastalk-0.3.0
- old
+ new
@@ -10,24 +10,24 @@
# <p>replacement html <%= body %></p>
module Extensions
SNIPPETS_FOLDER=File.join(File.dirname(__FILE__), 'snippets')
@@extensions = []
- def extension(start, stop = nil, new_line = false, &block)
+ def extension(start, stop = nil, &block)
re_start = Regexp.escape(start)
- re_stop = stop == '$' ? stop : Regexp.escape(stop || start)
- regex = Regexp.new("#{re_start}(.*?)(#{re_stop}+)", new_line ? 0 : Regexp::MULTILINE)
+ re_stop = Regexp.escape(stop || start)
+ regex = Regexp.new("#{re_start}(.*?)(#{re_stop}+)", Regexp::MULTILINE)
@@extensions << [regex, block]
end
def extensions
return @@extensions unless @@extensions.empty?
Dir.foreach(SNIPPETS_FOLDER) do |file|
next if file == '.' || file == '..'
content = File.read(File.join(SNIPPETS_FOLDER, file))
- start, stop, new_line = args(content)
- extension(start, stop, new_line == 'false') do |body|
+ start, stop = args(content)
+ extension(start, stop) do |body|
ERB.new(remove_syntax_from(content)).result(binding)
end
end
@@extensions