Sha256: 55bbc4344e3771b01fde704da6c300c7af0db84d801b378005384b213e393d14

Contents?: true

Size: 604 Bytes

Versions: 3

Compression:

Stored size: 604 Bytes

Contents

module Trestle
  module FlashHelper
    def normalize_flash_alert(flash)
      flash.is_a?(Hash) ? flash.with_indifferent_access : { message: flash }
    end

    def debug_form_errors?
      Trestle.config.debug_form_errors && instance_has_errors?
    end

    def instance_has_errors?
      instance.errors.any? rescue false
    end

    def turbo_stream_update_flash
      <<-EOF
      <turbo-stream action="update" target="flash">
        <template>
          #{render_to_string(partial: "trestle/flash/flash", formats: [:html])}
        </template>
      </turbo-stream>
      EOF
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trestle-0.10.0 app/helpers/trestle/flash_helper.rb
trestle-0.10.0.pre2 app/helpers/trestle/flash_helper.rb
trestle-0.10.0.pre app/helpers/trestle/flash_helper.rb