Where to put reusable code?
Re-usable template code should ideally be in its own template, backed by its own theme function:

function THEME_theme() {
  return [
    'foo_partial' =&gt; [
      'variables' =&gt; ['node' =&gt; NULL],
    ],
  ];
}


foo-partial.tpl.php:

&lt;div class="submitted"&gt;
    &lt;div class="created"&gt;
      &lt;span&gt;Created by &lt;?php print $node-&gt;name; ?&gt; on &lt;?php print format_date($node-&gt;created, $type = 'medium'); ?&gt;.&lt;/span&gt;
    &lt;/div&gt;
    &lt;div class="revised"&gt;
      &lt;span&gt;Last revised by &lt;?php print (user_load($node-&gt;revision_uid)-&gt;name); ?&gt; on &lt;?php print format_date($node-&gt;changed, $type = 'medium'); ?&gt;.&lt;/span&gt;
    &lt;/div&gt;
  &lt;/div&gt;


There are a number of different permutations you could use to actually get that HTML into the node template, here's one of them:

function THEME_preprocess_node(&amp;$vars) {
  if ($vars['node']-&gt;type == 'page' &amp;&amp; $vars['display_submitted']) {
    $vars['submitted_html'] = [
      '#theme' =&gt; 'foo_partial',
      '#node' =&gt; $vars['node'],
    ];
  }
}


node.tpl.php

...
&lt;?php
if ($display_submitted &amp;&amp; $submitted_html):
  echo render($submitted_html);
endif;
?&gt;
...