lib/custom_helpers.rb
# Display svg images inline
# optionally pass a string to use as the html class(es)
Display svg images inline
optionally pass a string to use as the html class(es)
Display svg images inline optionally pass a string to use as the html class ( es )
def svg(name, classes: [])
    root = Middleman::Application.root
    file_path = "#{root}/source/images/svg/#{name}.svg"
    if File.exists?(file_path)
      f = File.read(file_path)
      if classes.any?
        return f.gsub('<svg ', "<svg class='#{classes.join(' ')}'")
      else
        return f
      end
    else
      return '(not found)'
    end
  end
def svg ( name , classes : [ ] ) root = Middleman :: Application . root file_path = "#{root}/source/images/svg/#{name}.svg" if File . exists? ( file_path ) f = File . read ( file_path ) if classes . any? return f . gsub ( '<svg ' , "<svg class='#{classes.join(' ')}'" ) else return f end else return '(not found)' end end
Display svg images inline
optionally pass a string to use as the html class(es)
Display svg images inline optionally pass a string to use as the html class ( es )
name
classes