hyper-mesh icon indicating copy to clipboard operation
hyper-mesh copied to clipboard

add `#html_attr_name` method

Open catmando opened this issue 7 years ago • 3 comments

just a handy helper to add the ActiveRecordBase (on the client) (it would jus be added to InstanceMethods module)

  def html_attr_name(attr)
    "#{model_name}#{to_key}-#{attr}"
  end

See https://github.com/ruby-hyperloop/hyper-react/issues/244 for details on to_key

catmando avatar Feb 09 '18 22:02 catmando

This seems less useful than to_key unless for and name params do some magic, which I think they probably shouldn't. As there's no obvious "right" way of naming for/name in HTML (there's probably multiple competing conventions like there are with BEM/OO CSS etc), so I guess many would override this anyway, so we could just leave them to add it in ApplicationRecord themselves.

If Hyerloop had its own form_builder replacement smart input components then this would be a part of it.

But a one size fits all form builder is hard. The Rails one isn't flexible enough to work with frameworks like Bootstrap, so then there was SimpleForm but that's nowhere near simple, I hate it. I'd suggest holding off on this issue until we have a more concrete use-case for it.

sfcgeorge avatar Feb 09 '18 22:02 sfcgeorge

are the conventions used by any code? As in would I ever "have" to use the convention, or is it just simply a convention to keep things tidy. In which case it seems like it might be helpful. but I dunno. We can drop it from 1.0 if all agree...

catmando avatar Feb 09 '18 23:02 catmando

See https://github.com/ruby-hyperloop/hyper-react/issues/245 for how I use this in a smart form input component. Simply some human readable and useful yet unique identifier to link name and from

sfcgeorge avatar Feb 09 '18 23:02 sfcgeorge