app/helpers/application_helper.rb
# render a svg img as inline code
render a svg img as inline code
render a svg img as inline code
def svg(name)
    file_path = "#{Rails.root}/app/assets/images/#{name.gsub('.svg', '')}"
    svg = "#{file_path}.svg"
    return File.read(svg).html_safe if File.exist?(svg)
    png_path = "#{file_path}.png"
    png = "#{name}.png"
    puts png
    return image_tag(png) if File.exist?(png_path)
    "No SVG or PNG found at: #{file_path}"
  end
def svg ( name ) file_path = "#{Rails.root}/app/assets/images/#{name.gsub('.svg', '')}" svg = "#{file_path}.svg" return File . read ( svg ) . html_safe if File . exist? ( svg ) png_path = "#{file_path}.png" png = "#{name}.png" puts png return image_tag ( png ) if File . exist? ( png_path ) "No SVG or PNG found at: #{file_path}" end
render a svg img as inline code
render a svg img as inline code
name