Rack-based HTML rewriter
This commit is contained in:
parent
1006739e98
commit
927a1758ba
4 changed files with 110 additions and 73 deletions
|
@ -222,6 +222,19 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
def rewrite_paths(body, path, exts, &block)
|
||||
body.dup.gsub(/([=\'\"\(]\s*)([^\s\'\"\)]+(#{Regexp.union(exts)}))/) do |match|
|
||||
opening_character = $1
|
||||
asset_path = $2
|
||||
|
||||
if result = yield(asset_path)
|
||||
"#{opening_character}#{result}"
|
||||
else
|
||||
match
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Is mime type known to be non-binary?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue