Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>λ</title>
 <script class="jsbin" src="http://code.jquery.com/jquery-1.7.1.js"></script>
  <script class="jsbin" src="http://code.jquery.com/ui/jquery-ui-git.js"></script>
</head>
<body>
</body>
</html>
 
$.widget( "demo.templatedWidget", {
  _createWidget: function( options, element ) {
    if ( !element ) {
      element = $( options.template( options ) ).appendTo( "body" );
    }
    this._super( options, element );
  },
});
$.demo.templatedWidget({
  template: function( data ) {
    return "<div class='{{classes}}'>{{val}}</div>".replace( /{{([^}]+)}}/g, function( _, prop ) {
      return data[ prop ];
    });
  },
  classes: "this is a test",
  val: "look at me!"
});
    
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers