This plugin is capable of extracting metadata from classes, random attributes, and child elements.
data-corner attribute, which of course isn't standard conform markup. However browsers happily ignore attributes that they don't understand. So that's not a problem in real live.
Load the plugin as required for the current page:
%JQREQUIRE{"mynewplugin"}%
This is how the markup looks like:
<div class="jqMyNewPlugin {key1:'value1', key2:'value2', key3:'value3'}">
<div>
This is the plugin's initializer reading the metadata:
jQuery(function($) {
  var defaults = {
    key1: 'default1',
    key2: 'default2',
    key3: 'default3'
  };
  // find all elements tagged .jqMyNewPlugin that aren't init'ed yet
  // ... using livequery instead of each to trigger initialisation of async content
  $(".jqMyNewPlugin:not(jqInitedMyNewPlugin)").livequery(function() {
     // create a jQuery object for this
     var $this = $(this);
     // prevent the markup to be init'ed multiple times
     $this.addClass("jqInitedMyNewPlugin");
     // get plugin options by merging defaults and current json objs
     var opts = $.extend({}, defaults, $this.metadata());
     // call the plugin handler
     $this.myNewPlugin(opts);
  });
});
 Copyright © by the contributing authors. All material on this site is the property of the contributing authors.
Copyright © by the contributing authors. All material on this site is the property of the contributing authors.