Skip to content

Instantly share code, notes, and snippets.

@wejrowski
wejrowski / css_urlstrip.rb
Last active December 15, 2015 01:59
CSS image parser
urls = ""
DATA.each do |l|
img = l[/url\([^)]*\)/]
urls << "<img src=#{img.gsub(/url\(([^)]*)\)/, '\1')} /><hr />\n" if img
end
f = File.open("urltest.html", "w") {|file| file.truncate(0) } # Clear file contents
f = File.open("urltest.html", "w")
f.write urls
f.close
@wejrowski
wejrowski / block-to-partial
Created August 17, 2011 22:10
Passing Blocks to Rails partials
<%
#
# I originally needed to create a sidebar partial that had a div area where I could place custom links into. Finally found it.
# When I was trying to figure this out before and realized I needed to pass the view into :layout, rather than just using render 'layout'. Not sure why the block can't be passed otherwise but nonetheless...
#
# For explanation of options see
# http://guides.rubyonrails.org/layouts_and_rendering.html#options-for-render
#
%>