Sha256: e63fcaf51816436d41611097e137402e2f372cbdc93c81c1b99a37790d8612f6

Contents?: true

Size: 644 Bytes

Versions: 5

Compression:

Stored size: 644 Bytes

Contents

module <%= config[:camel_cased_app_name] %>
  module View
    class Context
      attr_reader :attrs

      def initialize(attrs = {})
        @attrs = attrs
      end

      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

      def with(new_attrs)
        self.class.new(attrs.merge(new_attrs))
      end

      private

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-web-roda-0.11.0 lib/dry/web/roda/templates/view__context.rb.tt
dry-web-roda-0.10.0 lib/dry/web/roda/templates/view__context.rb.tt
dry-web-roda-0.9.1 lib/dry/web/roda/templates/view__context.rb.tt
dry-web-roda-0.9.0 lib/dry/web/roda/templates/view__context.rb.tt
dry-web-roda-0.8.0 lib/dry/web/roda/templates/view_context.rb.tt