Skip to content
typesafe baseclass for Typesafe::XHTML::Writer
Perl 6
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status

Baseclass to be used with Typesafe::XHTML::Writer. It overloads infix:<~> to guard against omision of HTML-element quotation. This is not a DOM implementation, it's merely a secure way to concatanate HTML and non-HTML strings. It's lightweight by design, resulting in fairly good speed.

The only characters that are turned into HTML-Entities are < and &. If you need more use a modules that does not focus on speed.


use v6;
use Typesafe::HTML;

my $html ='<p>this will not be quoted</p>');
$html ~= '<p>this will</p>';
$html = $html ~ '& this will also be quoted';
$html = '& this prefix too' ~ $html;

dd $html;

# OUTPUT: HTML $html ='&amp; this prefix too<p>this will not be quoted</p>&lt;p>this will&lt;/p>&amp; this will also be quoted');

$html = ~ '& more quoting';

dd $html;

# OUTPUT: HTML $html ='&amp; more quoting');

put $html.Str;

# OUTPUT: &amp; more quoting


(c) Wenzel P. P. Peppmeyer, Released under Artistic License 2.0.

You can’t perform that action at this time.