Rubric::Entry::Formatter::HTMLEscape - format into HTML by escaping entities


Rubric documentation Contained in the Rubric distribution.

Index


Code Index:

NAME

Top

Rubric::Entry::Formatter::HTMLEscape - format into HTML by escaping entities

VERSION

Top

version 0.147

DESCRIPTION

Top

This formatter only handles formatting to HTML, and outputs the original content with HTML-unsafe characters escaped and paragraphs broken.

This is equivalent to filtering with Template::Filters' html and html_para filters.

METHODS

Top

TODO

Top

AUTHOR

Top

Ricardo SIGNES, <rjbs@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-rubric@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT

Top


Rubric documentation Contained in the Rubric distribution.
use strict;
use warnings;
package Rubric::Entry::Formatter::HTMLEscape;
our $VERSION = '0.147';

use Template::Filters;

my ($filter, $html, $para);
{
  my $filters = Template::Filters->new;
  $html = $filters->fetch('html');
  $para = $filters->fetch('html_para');

  $filter = sub {
    $para->( $html->($_[0]) );
  }
}

sub as_html {
  my ($class, $arg) = @_;
  return '' unless $arg->{text};
  return $filter->($arg->{text});
}

sub as_text {
  my ($class, $arg) = @_;
  return '' unless $arg->{text};
  return $html->($arg->{text});
}

1;