Class: RubyUI::MaskedInput

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_ui/masked_input/masked_input.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Constructor Details

#initialize(save_unmasked: false, **attrs) ⇒ MaskedInput

Returns a new instance of MaskedInput.



5
6
7
8
# File 'lib/ruby_ui/masked_input/masked_input.rb', line 5

def initialize(save_unmasked: false, **attrs)
  @save_unmasked = save_unmasked
  super(**attrs)
end

Instance Method Details

#view_templateObject



10
11
12
13
14
15
16
17
# File 'lib/ruby_ui/masked_input/masked_input.rb', line 10

def view_template
  if @save_unmasked
    Input(type: "text", **attrs.merge(name: "#{attrs[:name]}-masked"))
    input(type: "hidden", name: attrs[:name], value: attrs[:value])
  else
    Input(type: "text", **attrs)
  end
end