app/controllers/lookbook/previews_controller.rb in lookbook-1.0.0.beta.5 vs app/controllers/lookbook/previews_controller.rb in lookbook-1.0.0.beta.6
- old
+ new
@@ -45,10 +45,20 @@
def show_legacy
Lookbook.logger.warn("Legacy URL path detected. These paths are deprecated and will be removed in a future version")
redirect_to lookbook_inspect_path params[:path]
end
+ # Namespaced preview helpers
+
+ def lookbook_display(key, fallback = nil)
+ params.dig(:lookbook, :display, key.to_sym) || fallback
+ end
+
+ def lookbook_data(key, fallback = nil)
+ Lookbook.data.get(key, fallback)
+ end
+
private
def lookup_entities
@example = Lookbook.previews.find_example(params[:path])
if @example.present?
@@ -96,14 +106,15 @@
@example.params.each do |param|
if preview_controller.params.key?(param[:name])
preview_controller.params[param[:name]] = Lookbook::Params.cast(preview_controller.params[param[:name]], param[:type])
end
end
- # set display params
+ # set display and data params
preview_controller.params.merge!({
lookbook: {
- display: @example.display_params
+ display: @example.display_params,
+ data: Lookbook.data
}
})
end
end
@@ -143,10 +154,11 @@
@inspector_data ||= Lookbook::Store.new({
context: context_data,
preview: preview,
examples: examples,
- components: preview.components,
+ example: example,
+ data: Lookbook.data,
app: Lookbook
})
end
def panels