Sha256: 53ac9dcd49b815a5973a1de033fcfc7947074604ea349481204ee3084ad4a396
Contents?: true
Size: 1 KB
Versions: 9
Compression:
Stored size: 1 KB
Contents
module Lookbook module PageHelper include Utils def page_path(id) page = id.is_a?(Page) ? id : Lookbook.pages.find(id) lookbook_page_path page.lookup_path end def embed(*args, params: {}, type: :preview, **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 if example @embed_counter += 1 render_component "embed", id: generate_id("embed", url_for, example.lookup_path, @embed_counter - 1), example: example, params: params, opts: opts else embed_not_found end end protected def embed_not_found render_component "not_found", { title: "Preview not found", text: "The preview may have been renamed or deleted." } end end end
Version data entries
9 entries across 9 versions & 1 rubygems