Template::Plugin::Nbsp - TT2 plugin that inserts non-breaking space


Template-Plugin-Nbsp documentation Contained in the Template-Plugin-Nbsp distribution.

Index


Code Index:

NAME

Top

Template::Plugin::Nbsp - TT2 plugin that inserts non-breaking space (usefull for empty table cells)

SYNOPSIS

Top

  [% USE Nbsp %]

  <table>
    <tr>
      <td>[% variable | nbsp %]</td>
    </tr>
  </table>

DESCRIPTION

Top

This plugin helps preventing empty table cells. If the value is undef or empty it returns &nbsp;.

NOTE

Top

If you use cascading style sheets (css), you can use empty-cells: show; to get the same results without this plugin.

AUTHOR

Top

Uwe Voelker <uwe.voelker@gmx.de>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Top

Template


Template-Plugin-Nbsp documentation Contained in the Template-Plugin-Nbsp distribution.

package Template::Plugin::Nbsp;
$VERSION = 0.01;

use strict;
use base 'Template::Plugin';

sub new {
    my ($self, $context) = @_;

    $context->define_filter('nbsp', \&nbsp, '');

    return $self;
}

sub nbsp {
    my $text = shift;

    # undef?
    return '&nbsp;' unless defined $text;

    # empty string?
    return '&nbsp;' if ($text eq '');

    return $text;
}


1;
__END__