Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5682 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

[PATCH] $w() addition to Prototype

Reported by: glazedginger@gmail.com Assigned to: sam@conio.net
Priority: low Milestone:
Component: Prototype Version:
Severity: trivial Keywords: $A array $w %w
Cc: mislav

Description

Just a small add on to Protoype which I proposed here and which Thomas Fuchs thought was notable enough to mention in one of his posts.

It's basically just a ruby inspired shorthand syntax to write arrays:

$w('div span p ul ol li dl dt em strong')

instead of this:

['div', 'span', 'p', 'ul', 'ol', 'li', 'dl', 'dt', 'em', 'strong']

There's a small gain on size and it's more expressive, it's probably less error prone too... and it looks rather nice ;-)

The only caveat is a tiny loss on execution speed.

Attachments

array.diff (342 bytes) - added by glazedginger@gmail.com on 07/11/06 13:28:00.
array.html.diff (0.7 kB) - added by brandon.aaron@gmail.com on 09/06/06 15:16:31.
The unit tests.

Change History

07/11/06 13:28:00 changed by glazedginger@gmail.com

  • attachment array.diff added.

09/03/06 20:43:47 changed by madrobby

  • status changed from new to closed.
  • resolution set to untested.

09/06/06 15:16:31 changed by brandon.aaron@gmail.com

  • attachment array.html.diff added.

The unit tests.

09/06/06 15:17:18 changed by brandon.aaron@gmail.com

  • status changed from closed to reopened.
  • resolution deleted.

I've added some tests.

(follow-up: ↓ 4 ) 10/02/06 22:35:09 changed by mislav

Pretty! I want this too!

(in reply to: ↑ 3 ) 10/03/06 05:11:59 changed by Tobie

Replying to mislav:

Pretty! I want this too!

In the meantime, you can always grab it from here: http://tobielangel.com/javascripts/xprototype.js

11/06/06 16:15:08 changed by mislav

  • cc set to mislav.

12/05/06 19:12:09 changed by madrobby

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [5679]) Prototype: Add $w() to easily create arrays from strings like Rubys %w, fixes #5682 [glazedginger, brendon.aaron]