Skip to content

Instantly share code, notes, and snippets.

@datapimp
Created June 29, 2011 15:38
Show Gist options
  • Select an option

  • Save datapimp/1054114 to your computer and use it in GitHub Desktop.

Select an option

Save datapimp/1054114 to your computer and use it in GitHub Desktop.
App.util.parse_content_location = (location)->
# parts = ["content_packages","1","sections","1"]
# parent class, parent id, content item class, content item id
parts = location.split(':')
App.util.find_object_for_location = (content_location)->
[pkg, pkg_id, store, object_id] = App.util.parse_content_location(content_location)
# find the table based on the store variable
collection = Store(store)
# fetch the item from the table based on the object_id variable
return collection.get object_id if collection? and object_id?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment