Sha256: 287529a3266c4432e0a1c4d31bd8d3649a725de226d9d8f6f2f774068da3c20d
Contents?: true
Size: 927 Bytes
Versions: 7
Compression:
Stored size: 927 Bytes
Contents
# frozen_string_literal: true # Add a check-box, either specifying everything manually or using a model object on the form # # == Basic usage: # {%check_box name:"name" value:"1"%} # # == Advanced usage: # {%check_box name%} # # This last usage requires a model on the form # class CheckBoxTag < LiquidumTag def render(context) super if @form_model %[<input ] + attr_str(:name, arg(:name), input(:name, argv1)) + %[value="0" type="hidden"/>] else %[<input ] + attr_str(:name, arg(:name), input(:name, argv1)) + attr_str(:id, arg(:id), input(:id, argv1)) + attr_str(:value, arg(:value), input(:value, argv1) ? 1 : 0) + attr_str(:checked, arg(:checked), input(:checked, argv1)) + attrs_str(:disabled, :maxlength, :placeholder, :class) + %[ type="checkbox"/>] end end end Liquid::Template.register_tag('check_box', CheckBoxTag)
Version data entries
7 entries across 7 versions & 1 rubygems