Sha256: e944b189184f104d23247c0182e256fbedf5de45708661e3a3366ee4d18d8613
Contents?: true
Size: 848 Bytes
Versions: 7
Compression:
Stored size: 848 Bytes
Contents
# frozen_string_literal: true # Add a text-field, either specifying everything manually or using a model object on the form # # == Basic usage: # {%text_field name:"name" value:"Pencil"%} # # == Advanced usage: # {%text_field name%} # # This last usage requires a model on the form # class TextFieldTag < LiquidumTag attr_accessor :field_type def initialize(tag, args, tokens) super @field_type = 'text' end def render(context) super result = %[<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)) result += attrs_str(reject: %[name value id]) result += %[ type="#{field_type}"/>] result end end Liquid::Template.register_tag('text_field', TextFieldTag)
Version data entries
7 entries across 7 versions & 1 rubygems