The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Template::Semantic::Document - Template::Semantic Result object

SYNOPSIS

  my $out = Template::Semantic->process('template.html', {
      'title, h1' => 'foo',
  });
  
  my $out = Template::Semantic->process('template.html', {
      '.foo, .bar' => 'baz',
      '.mee@class' => 'moo',
  })->process({
      '#boo@src' => 'grr',
      '#yea .ye' => 'yoo',
  })->process({
      '.foo' => sub { uc },
      '.bar' => sub { lc },
  });
  
  print $out;
  print $out->as_string; # same as avobe

METHODS

$out = $out->process( \%vars )

Process again to the result and returns Template::Semantic::Document object again. So you can chain

  Template::Semantic->process(...)->process(...)
"$out" (stringify)

Calls as_string() internally.

$html = $out->as_string( %options )

Returns the result as XHTML/XML.

  • is_xhtml => [1|0]

    Default value is true. Even if DTD is not defined in the template, outputs as XHTML. When sets is_xhtml false, skip this effect.

      my $out = $ts->process(\<<END);
      <div>
          <img src="foo" />
          <br />
          <textarea></textarea>
      </div>
      END
      ;
      
      print $out;
      
      <div>
          <img src="foo" />
          <br />
          <textarea></textarea>
      </div>
      
      print $out->as_string(is_xhtml => 0);
      
      <div>
          <img src="foo"/>
          <br/>
          <textarea/>
      </div>
$dom = $out->dom()
  my $out  = Template::Semantic->process($template, ...);
  my $dom  = $out->dom;
  my $root = $dom->documentElement; # get root element

Gets the result as XML::LibXML::Document.

SEE ALSO

Template::Semantic

AUTHOR

Naoki Tomita <tomita@cpan.org>