Browsing projects by Tag(s)

Select a tag to browse associated projects and drill deeper into the tag cloud.

Showing page 1 of 1

The focus is to extend the language, modifying the base classes to add several handy methods and shortcuts. It works on top of Prototype and extends the core classes somewhat to the same extent than ActiveSupport extends ruby's core to make a lot of stuff pretty. For example, you can do things ... [More] like: (10).minutes().fromNow() //=> Date object ten minutes in the future "person".pluralize() //=> "people" ["dog", "cat", "mouse"].toSentence() //=> "dog, cat and mouse" Date.now().strftime("It's %H:%M") //=> "It's 16:23"Plus several other stuff, like string interpolation (a la Ruby), so you get: var name = "johnny"; $Q("Hello, my name is #{name.capitalize()}"); //=> "Hello, my name is JohnnyAnd you can even interpolate inside objects! For example, let's suppose you have the following class: var Dog = Class.create(); Dog.prototype = { initialize: function(name) { this.name = name; }, woof: function() { return "woof!"; } } var bobby = new Dog("bobby");You can use interpolation inside the class passing the binding to $Q as a second parameter : Dog.prototype.greet = function() { $Q("I'm #{this.name} and I #{this.woof()}", this); //=> "I'm bobby and I woof!" }Or you can do this even outside classes: $Q("It's #{this.getMinutes()} after #{this.getHours()}", new Date());So whatever you pass to $Q on the second parameter becomes what "this" points to inside the strings. And there's a whole other world of stuff for you to discover (and for me --and whoever wants to help-- to document), so check out the code and start marvelling at the flexibility of JavaScript, and the wonders of ActiveSupport ;) [Less]

0
 
  0 reviews  |  0 users  |  4,532 lines of code  |  0 current contributors  |  Analyzed 9 days ago
 
 
 
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.