Sha256: 2cd760eb73842c9b67599c1d9e7301371048735f0263fc0cb512e58ee2b4dba9
Contents?: true
Size: 927 Bytes
Versions: 2
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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lookbook-1.0.0.beta.1 | app/helpers/lookbook/page_helper.rb |
lookbook-1.0.0.beta.0 | app/helpers/lookbook/page_helper.rb |