Sha256: 9bbfe1c0c29113fc9c9bd088f74321c33ccf379802a7d650eeeea7ce4476680a
Contents?: true
Size: 1.03 KB
Versions: 7
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true # Add a text-field, either specifying everything manually or using a model object on the form # # == Basic usage: # {%assign airports = "Eindhoven, Schiphol" | split: ', '%} # {%options_for_select airports%} # # == Advanced usage: # {%assign airports = "Eindhoven, Schiphol" | split: ', '%} # {%options_for_select airports selected:"Schiphol" disabled:"Eindhoven"%} # # == Advanced usage: # {%options_for_select airports name value selected:"Schiphol" disabled:"Eindhoven"%} # # This last usage requires a model on the form # class OptionsForSelectTag < LiquidumTag def render(context) super options = argv1.map(&:to_liquid) if sargs.present? options = options.map do |option| result = sargs.map { |a| option[a.to_s] } result = result.first if result.length == 1 result end end context.registers['controller'].helpers.options_for_select(options, attr_args).to_s end end Liquid::Template.register_tag('options_for_select', OptionsForSelectTag)
Version data entries
7 entries across 7 versions & 1 rubygems