app/components/lookbook/params_editor/field/component.rb in lookbook-1.0.0.rc.2 vs app/components/lookbook/params_editor/field/component.rb in lookbook-1.0.0.rc.3

- old
+ new

@@ -1,7 +1,9 @@ module Lookbook class ParamsEditor::Field::Component < Lookbook::BaseComponent + attr_reader :name + def initialize(input:, name:, default: nil, value: nil, input_type: nil, type: nil, options: nil, **html_attrs) @input = input @name = name @value = value @default_value = default @@ -10,11 +12,11 @@ @options = options super(**html_attrs) end def label - @name.titleize + name.titleize end def value val = @value.presence || @default_value @type == "Boolean" ? val == "true" || val == true : val @@ -29,11 +31,11 @@ end protected def alpine_data - escaped_value = value.is_a?(String) ? helpers.j(value) : value - "{name: '#{@name}', value: '#{escaped_value}'}" + escaped_value = helpers.raw json_escape(value.to_json) + "{name: '#{name}', value: #{escaped_value}}" end def alpine_component "paramsEditorFieldComponent" end