theme hook and rendering I am trying to get my head around the drupal 7 render() function but there is something I can't get straight.

The data source that I want to render looks like this:

Array
(
    [id] =&gt; 3315539862007
    [name] =&gt; Some Name
    [picture] =&gt; some-facebook-image.jpg
    [link] =&gt; http://www.facebook.com/some-page


I pass it to a $block['content'] like this (I also tried changing '#children' to '#element', but with no success):

$block['content'] = array(
  '#theme' =&gt; 'opengraph_company',
  '#children' =&gt; $data
);


but inside my custom theming function the data that is passed looks really weird

function theme_opengraph_company($variables) {
  $element = $variables['element'];

  return 'hello';
}


if I debug the $variables inside the theming function I get something like this

Array
(
    [element] =&gt; Array
        (
            [#theme] =&gt; opengraph_company
            [#children] =&gt; Array
                (
                    [id] =&gt; 3315539862007
                    [name] =&gt; Some Name


which to me looks really weird. The MYMODULE_theme function looks like this

function opengraph_theme() {
  return array(
      'opengraph_company' =&gt; array(
      'render element' =&gt; 'element',
    ),
  );
}


I would expect access to the data based to the theming function to easier, something like 

function theme_opengraph_company($variables) {
  $element = $variables['element'];

  return $element['name'];
}


Am I passing the parameters wrong to the theming function?
When you use render element, the element which you apply the theme to is passed into the theme function in the $vars array...the index in the array will be whatever you've set render element to in your theme function, which in this case is element; hence the element you've asked the theme API to pass in is available in $vars['element'], which is a carbon copy of the original render element.

To get the effect you're looking for you would normally use variables instead of render element:

function opengraph_theme() {
  return array(
    'opengraph_company' =&gt; array(
      'variables' =&gt; array(
        'id' =&gt; 0,
        'name' =&gt; '',
        'picture' =&gt; '',
        'link' =&gt; ''
      ),
    ),
  );
}


Then you'd build your render element like this:

$block['content'] = array(
  '#theme' =&gt; 'opengraph_company',
  '#id' =&gt; 123,
  '#name' =&gt; 'Name',
  '#picture' =&gt; 'Picture',
  '#link' =&gt; 'Link'
);


Or, if you want to use your current $data array, you can pass it directly to the theme function:

$block['content'] = array(
  '#markup' =&gt; theme('opengraph_company', $data)
);


Bear in mind with that second method any modules whose hooks might be run after yours will no longer get the chance to alter the theme output, as you're converting it down to a string.

Using either of those methods though, when your theme function is run you will have access to the variables like this:

function theme_opengraph_company(&amp;$vars) {
  $id = $vars['id'];
  $name = $vars['name'];
  // etc...
}