module HtmlHelper # Returns class_name if x equals y # # @param {String} class_name # @param {Mixed} x # @param {Mixed} y # @param {Boolean} exact # # @return {String} def css_class(class_name, x, y = true, exact = false) if exact class_name if (x === y) else class_name if (x == y) end end # Returns CSS body class # By default it shows the current controller & action # You can add items by using @body_class # # @return {String} def body_class body_class = [ params[:controller], params[:action] ] body_class << @body_class if @body_class body_class.join(" ") end # Return CSS background-image style # # @return {String} def css_bg_img(img_url = nil) "background-image: url('#{img_url}');" end # Returns HTML for all favicons links # Generate icons & code: http://iconogen.com/ # # @return {String} def favicons raw <<-HEREDOC HEREDOC end # Includes inline SVG # # @param {String} path # # @return {String} def inline_svg(path) File.open("app/assets/images/#{path}", "rb") do |file| raw file.read end end # When on .mrhenry.eu domain, we don't want a search crawler to index # # @return {String} def meta_name_robots if request.host.match /.*\.a\.mrhenry\.eu.*/ tag("meta", name: "robots", content: "noindex, nofollow") else tag("meta", name: "robots", content: "index, follow") end end # Render partial # def render_partial(partial_name, locals={}, &block) render partial: partial_name, locals: locals.merge({ block: block }) end end