Sha256: f3c56c2a27d445bbfd525fbf69982fc5b30d4ad8b34ca62a78b34f9058e5b57b
Contents?: true
Size: 927 Bytes
Versions: 1
Compression:
Stored size: 927 Bytes
Contents
module Lookbook module PageHelper include Utils def page_path(id) page = id.is_a?(Page) ? id : Lookbook.pages.find(id) if page.present? lookbook_page_path page.lookup_path else Lookbook.logger.warn "Could not find page with id ':#{id}'" end end def embed(*args, params: {}, type: :preview, max_height: nil, **opts) return unless args.any? @embed_counter ||= 0 preview_lookup = args.first.is_a?(Symbol) ? args.first : preview_class_name(args.first) preview = Lookbook.previews.find(preview_lookup) example = args[1] ? preview&.example(args[1]) : preview&.default_example embed_id = "#{url_for}/embed/#{example.lookup_path}".delete_prefix("/").tr("/", "-") render_component :embed, id: embed_id, example: example, params: params, max_height: max_height, opts: opts end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lookbook-1.0.0.beta.2 | app/helpers/lookbook/page_helper.rb |