[% BLOCK external_link %]
<a href="[% link.url | evaltt %]" target="_blank">
     <span class="label label-default"><i class="icon-external-link"></i> [% link.displayname | html_entity %]</span></a>
[% END %]

[% BLOCK external_mac_links %]
  [% FOREACH link IN settings.external_links.node.reverse %]
    [% NEXT UNLESS link.for_mac %]
    [% mac_format = 'as_' _ (link.mac_format.lower || 'ieee') %]
    [% node = item.net_mac.$mac_format FILTER uri %]
    <span class="nd_node-ext-link">[% PROCESS external_link %]</span>
    <span class="nd_node-ext-link">&nbsp;</span>
  [% END %]
[% END %]

[% BLOCK external_ip_links %]
  [% FOREACH link IN settings.external_links.node %]
    [% NEXT UNLESS link.for_ip %]
    [% node = item.ip FILTER uri %]
    [% PROCESS external_link %]
  [% END %]
[% END %]

[% BLOCK external_device_links %]
  [% FOREACH link IN settings.external_links.device %]
    [% NEXT UNLESS permitted_by_acl(item, link) %]
    [% device   = item.ip FILTER uri %]
    [% fqdn     = item.dns FILTER uri %]
    [% sysname  = item.name FILTER uri %]
    [% mac      = item.mac FILTER uri %]
    [% serial   = item.serial FILTER uri %]
    [% hostname = item.dns.remove(settings.domain_suffix) FILTER uri %]
    [% FOREACH config IN settings._extra_device_details %]
      [% NEXT UNLESS config.field.match('^cf_') %]
      [% ${config.field} = item.${config.field} FILTER uri %]
    [% END %]
    [% PROCESS external_link %]
  [% END %]
[% END %]

[% BLOCK external_device_port_links %]
  [% FOREACH link IN settings.external_links.device_port %]
    [% NEXT UNLESS permitted_by_acl(item, link) %]
    [% device   = d.ip FILTER uri %]
    [% fqdn     = d.dns FILTER uri %]
    [% sysname  = d.name FILTER uri %]
    [% hostname = d.dns.remove(settings.domain_suffix) FILTER uri %]
    [% port     = item.port FILTER uri %]
    [% mac      = item.mac FILTER uri %]
    [% ifindex  = item.ifindex FILTER uri %]
    [% FOREACH config IN settings._extra_device_port_cols %]
      [% NEXT UNLESS config.field.match('^cf_') %]
      [% ${config.field} = item.${config.field} FILTER uri %]
    [% END %]
    [% PROCESS external_link %]
  [% END %]
[% END %]
