HTML::Widget::Element::Span - Span Element


HTML-Widget documentation Contained in the HTML-Widget distribution.

Index


Code Index:

NAME

Top

HTML::Widget::Element::Span - Span Element

SYNOPSIS

Top

    my $e = $widget->element( 'Span', 'foo' );
    $e->content('bar');

DESCRIPTION

Top

Span Element.

METHODS

Top

content

content() can contain a string, an HTML::Element object, or an array-ref of HTML::Element objects.

containerize

new

Sets allow_filter in HTML::Widget::Element to false, so that filters added by $widget->filter_all won't be applied to Span elements.

Sets allow_constraint in HTML::Widget::Element to false, so that constraints added by $widget->constraint_all won't be applied to Span elements.

SEE ALSO

Top

HTML::Widget::Element

AUTHOR

Top

Sebastian Riedel, sri@oook.de

LICENSE

Top

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


HTML-Widget documentation Contained in the HTML-Widget distribution.
package HTML::Widget::Element::Span;

use warnings;
use strict;
use base 'HTML::Widget::Element';

__PACKAGE__->mk_accessors(qw/content/);

sub containerize {
    my ( $self, $w ) = @_;

    my $content = $self->content;
    $self->attributes->{class} ||= 'span';
    my $e = HTML::Element->new( 'span', id => $self->id($w) );
    my @content
        = ( $content && ref($content) eq 'ARRAY' ) ? @$content : ($content)
        if defined $content;
    $e->push_content(@content) if @content;
    $e->attr( $_ => ${ $self->attributes }{$_} )
        for ( keys %{ $self->attributes } );

    return $self->container( { element => $e } );
}

sub new {
    my $self = shift->NEXT::new(@_);

    $self->allow_filter(0)->allow_constraint(0);

    return $self;
}

1;