Sha256: ea6de14aa3dbe3a9ad0865af19015094988e7e0890fea93987b3f8c0802ed156

Contents?: true

Size: 866 Bytes

Versions: 3

Compression:

Stored size: 866 Bytes

Contents

# encoding: UTF-8

module Spontaneous
  class Layout < Style
    def try_paths
      [["layouts", prototype.name.to_s]]
    end

    class Default < Layout
      # If no named layouts have been defined first look for a layout
      # matching the class of our owner, then default to the 'standard'
      # layout.
      def try_paths
        named_layout = self.class.to_directory_name(owner)
        [["layouts", named_layout], ["layouts", "standard"]]
      end
    end

    class Anonymous
      def initialize(templates = {})
        @templates = templates
      end

      def template(format = :html)
        template = @templates[format]
        # a layout without a format is used as a fallback
        template ||= @templates[nil]
        template
      end

      def name
        nil
      end

      def schema_id
        nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta4 lib/spontaneous/layout.rb
spontaneous-0.2.0.beta3 lib/spontaneous/layout.rb
spontaneous-0.2.0.beta2 lib/spontaneous/layout.rb