Skip to content

Instantly share code, notes, and snippets.

@anasnakawa
Created December 2, 2013 07:51
Show Gist options
  • Save anasnakawa/7746381 to your computer and use it in GitHub Desktop.
Save anasnakawa/7746381 to your computer and use it in GitHub Desktop.
parse binding attribute, the knockout way
// parse a data-bind attribute
//
// @param {string} attr
// @return {object} parsed binding object
//
// examples:
// ---------
// parseBindings( 'something: { cool: true }' ); // { something: { cool: true } }
function parseBindings( attr ) {
return new Function( "return { " + attr + " };" )();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment