Plugins - Dashed DOM_ID

StarAdd to favorites

Dashed DOM_ID

Inspired by http://codefluency.com/articles/2006/05/30/rails-views-active-record-dom-ids/

Introduction

The naming convention adopted is to split by - (dashes) —

i.e.

     person.dom_id                  # gives 'person-3'
     person.dom_id('name')          # gives 'person-3-name'
     person.dom_id('name', 'dummy') # gives 'dummy-3-name'

This allows splitting by - to obtain 3 logical portions:

    person.dom_id('name').split(/-/) # ['person', '3', 'name']

Related

The other convention is split by _ (underscores) http://topfunky.net/svn/plugins/dom_id/

My POV is that _ could potentially conflict with long names, e.g.

    senior_employee.dom_id('created_at') # senior_employee_45_created_at

With the _ convention, there is no convenient way to split that id into usable parts.

License

dashed_dom_id plugin is released under the MIT license.

Author

Chew Choon Keat http://blog.yanime.org/

Chew Choon Keat

http://choonkeat.svnrepository.com/svn/rails-plugins/dashed_dom_id/

Rails' (MIT)

  • Currently 4.2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?