Sha256: cd788c93089882cb6f9f5824b34e5d842e46f1051ba49aa351e6ab1e8b89fdf8

Contents?: true

Size: 461 Bytes

Versions: 6

Compression:

Stored size: 461 Bytes

Contents

require "dry/view/context"

module <%= config[:camel_cased_app_name] %>
  class ViewContext < Dry::View::Context
    def csrf_token
      self[:csrf_token]
    end

    def csrf_metatag
      self[:csrf_metatag]
    end

    def csrf_tag
      self[:csrf_tag]
    end

    def flash
      self[:flash]
    end

    def flash?
      %i[notice alert].any? { |type| flash[type] }
    end

    private

    def [](name)
      _options.fetch(name)
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
dry-web-roda-0.14.0 lib/dry/web/roda/templates/view_context.rb.tt
dry-web-web_pipe-0.2.0 lib/dry/web/web_pipe/templates/view_context.rb.tt
dry-web-roda-0.13.1 lib/dry/web/roda/templates/view_context.rb.tt
dry-web-roda-0.13.0 lib/dry/web/roda/templates/view_context.rb.tt
dry-web-web_pipe-0.1.0 lib/dry/web/web_pipe/templates/view_context.rb.tt
dry-web-roda-0.12.0 lib/dry/web/roda/templates/view_context.rb.tt