Sha256: 805a476d162ad51f7c1b9c2aada768e84d9bcd619d1e79b262f10be3d72414de

Contents?: true

Size: 741 Bytes

Versions: 12

Compression:

Stored size: 741 Bytes

Contents

module Lookbook
  class RenderedExample
    delegate_missing_to :example

    attr_reader :output, :example

    def initialize(example, output, params)
      @example = example
      @params = params
      @output = output
    end

    def source
      has_custom_template? ? template_source(template) : example.source
    end

    def source_lang
      has_custom_template? ? template_lang(template) : example.source_lang
    end

    protected

    attr_reader :params

    def render_args
      @_render_args ||= preview.render_args(example.name, params: params)
    end

    def template
      render_args[:template]
    end

    def has_custom_template?
      template != "view_components/preview" && !custom_source?
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
lookbook-1.5.5 lib/lookbook/rendered_example.rb
lookbook-1.5.4 lib/lookbook/rendered_example.rb
lookbook-1.5.3 lib/lookbook/rendered_example.rb
lookbook-1.5.2 lib/lookbook/rendered_example.rb
lookbook-1.5.1 lib/lookbook/rendered_example.rb
lookbook-1.5.0 lib/lookbook/rendered_example.rb
lookbook-1.4.5 lib/lookbook/rendered_example.rb
lookbook-1.4.4 lib/lookbook/rendered_example.rb
lookbook-1.4.3 lib/lookbook/rendered_example.rb
lookbook-1.4.2 lib/lookbook/rendered_example.rb
lookbook-1.4.1 lib/lookbook/rendered_example.rb
lookbook-1.4.0 lib/lookbook/rendered_example.rb