title: jQuery convert data-* attributes to lower camel case properties
body: <p>I have the following jQuery script to intialise a jQuery plugin called poshytips. I want configure the plugin using Html5 data attributes. I am repeating myself big time, can anyone come up with a better way to do this?</p>
  
  <pre><code>$('.poshytip-trigger').each(function (index) {
      var $this = $(this);
      var data = $this.data();
  
      var options = {};
  
      if (data['class-name']) {
          options.className = data['class-name'];
      }
  
      if (data['align-x']) {
          options.alignX = data['align-x'];
      }
  
      if (data['align-y']) {
          options.alignY = data['align-y'];
      }
  
      if (data['offset-y']) {
          options.offsetY = data['offset-y'];
      }
  
      if (data['offset-x']) {
          options.offsetX = data['offset-x'];
      }
  
      $this.poshytip(options);
  });
  </code></pre>