Sha256: 616a87dd6dffa24d2546a4ab75aa8453953cfffe915629f91da868f32a86a685
Contents?: true
Size: 959 Bytes
Versions: 6
Compression:
Stored size: 959 Bytes
Contents
module Lookbook module PageHelper include Utils def page_path(id) page = id.is_a?(Page) ? id : Lookbook.pages.find_by_id(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 = if args.first.is_a?(Symbol) Lookbook.previews.find_by_path(args.first) else Lookbook.previews.find_by_preview_class(args.first) end example = args[1] ? preview&.example(args[1]) : preview&.default_example embed_id = "#{url_for}/embed/#{example.lookup_path}".delete_prefix("/").tr("/", "-") lookbook_render :embed, id: embed_id, example: example, params: params, max_height: max_height, opts: opts end end end
Version data entries
6 entries across 6 versions & 1 rubygems