<commit_before>(function registerRenderLayout(){

  var dispatch = widget.layout.register( 'renderer', createRendererView, {
    description: "Creates a dynamic renderer via indirection, allowing complex data structures"
  } );

  function getRendererLayout( def )
  {
    var key = 'staticRenderer';
    var renderer = widget.get( def.layout, key );
    if( !renderer )
    {
      key = widget.get( def.layout, 'dynamicRenderer', 'Unknown Type' );
      if( 'object'==$.type(key) )
      {
        var dynamicKey = widget.util.expandPath( widget.get( def.layout, 'dynamicRendererKey', 'default' ), def.data );
        key = key[ dynamicKey ];
      }
      key = widget.util.expandPath( key, def.data );
      renderer = widget.util.get( 'renderers', key );
    }

    return {
      key: key,
      layout: renderer
    };
  }

  function renderPanel( def, renderer, key, panel )
  {
    def._currentRendererKey = key;

    if( panel )
      panel.empty().removeClass();
    else
      panel = $('<div/>' );

    panel.addClass( 'renderer' );
    if( key != 'staticRenderer' )
      panel.addClass( key );

    if( renderer && renderer.layout )
    {
      var dataStack = widget.util.getData( 'stack', [] );
      dataStack.unshift( def.data );

      var rendererOptions = $.extend( {}, renderer.options||{}, {
        rendererKey: key||'static'
      } );

      var optionsStack = widget.util.getData( 'meta', [] );
      optionsStack.push( rendererOptions );

      var rendererData = $.extend( {}, renderer.layout );

      var rendererView = dispatch( panel, rendererData, rendererOptions, undefined, dataStack );

      optionsStack.pop();
      dataStack.pop();
    }
    else
    {
      panel.append( $('<div/>', {text: key } ).addClass('title') );
      panel.append( $('<div/>', {text: JSON.stringify(data) } ).addClass('data') );
    }


    return panel;
  }

  function createRendererView( def )
  {
    var oldKey = def._currentRendererKey;

    var info = getRendererLayout( def );
    var panel = renderPanel( def, info.layout, info.key );

    panel.update = function updateRenderer( event, context ) {
      var newInfo = getRendererLayout( def );
      if( def._currentRendererKey != newInfo.key )
      {
        renderPanel( def, newInfo.layout, newInfo.key, panel );
      }
    };

    panel.appendTo( def.parent );
    return panel;
  }

})();
<commit_msg>null safety on renderers<commit_after>(function registerRenderLayout(){

  var dispatch = widget.layout.register( 'renderer', createRendererView, {
    description: "Creates a dynamic renderer via indirection, allowing complex data structures"
  } );

  function getRendererLayout( def )
  {
    var key = 'staticRenderer';
    var renderer = widget.get( def.layout, key );
    if( !renderer )
    {
      key = widget.get( def.layout, 'dynamicRenderer', 'Unknown Type' );
      if( 'object'==$.type(key) )
      {
        var dynamicKey = widget.util.expandPath( widget.get( def.layout, 'dynamicRendererKey', 'default' ), def.data );
        key = key[ dynamicKey ];
      }
      key = widget.util.expandPath( key, def.data );
      renderer = widget.util.get( 'renderers', key );
    }

    return {
      key: key,
      layout: renderer
    };
  }

  function renderPanel( def, renderer, key, panel )
  {
    def._currentRendererKey = key;

    if( panel )
      panel.empty().removeClass();
    else
      panel = $('<div/>' );

    panel.addClass( 'renderer' );
    if( key != 'staticRenderer' )
      panel.addClass( key );

    if( renderer && renderer.layout )
    {
      var dataStack = widget.util.getData( 'stack', [] );
      dataStack.unshift( def.data );

      var rendererOptions = $.extend( {}, renderer.options||{}, {
        rendererKey: key||'static'
      } );

      var optionsStack = widget.util.getData( 'meta', [] );
      optionsStack.push( rendererOptions );

      var rendererData = $.extend( {}, renderer.layout );

      var rendererView = dispatch( panel, rendererData, rendererOptions, undefined, dataStack );

      optionsStack.pop();
      dataStack.pop();
    }
    else
    {
      panel.append( $('<div/>', {text: key } ).addClass('title') );
      panel.append( $('<div/>', {text: JSON.stringify(def.data||{}) } ).addClass('data') );
    }


    return panel;
  }

  function createRendererView( def )
  {
    var oldKey = def._currentRendererKey;

    var info = getRendererLayout( def );
    var panel = renderPanel( def, info.layout, info.key );

    panel.update = function updateRenderer( event, context ) {
      var newInfo = getRendererLayout( def );
      if( def._currentRendererKey != newInfo.key )
      {
        renderPanel( def, newInfo.layout, newInfo.key, panel );
      }
    };

    panel.appendTo( def.parent );
    return panel;
  }

})();

{'fraction_non_alphanumeric': 0.14673345856814862, 'fraction_numerical': 0.0, 'mean_word_length': 2.644106463878327, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2603027', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1430, 'n_words': 341}