Sha256: c92402a2084d38f6af1623a29683b3fbaf07756db9c05f02f5b0c187ae675ddd
Contents?: true
Size: 915 Bytes
Versions: 15
Compression:
Stored size: 915 Bytes
Contents
# frozen_string_literal: true require "active_support/concern" module Decidim # This module allows creating flash messages that are HTML safe by providing # the flash[:html_safe] key in the flash hash. # # @example Setting HTML safe flash in a controller # class YourController # include Decidim::HtmlSafeFlash # # def create # YourRecord.create!(record_params) # # flash[:html_safe] = true # flash[:success] = t(".record_created_html") # end # end module HtmlSafeFlash extend ActiveSupport::Concern included do before_action :handle_html_safe_flash end private def handle_html_safe_flash html_safe = flash[:html_safe] flash.delete(:html_safe) return unless html_safe flash.each do |key, value| flash[key] = value.html_safe flash.discard(key) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems