Skip to content
typesafe baseclass for Typesafe::XHTML::Writer
Other
  1. Other 100.0%
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/Typesafe
t
.travis.yml
LICENSE
META.info
META6.json
README.md

README.md

Typesafe::HTML

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.

Usage:

use v6;
use Typesafe::HTML;

my $html = HTML.new('<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 = HTML.new('&amp; this prefix too<p>this will not be quoted</p>&lt;p>this will&lt;/p>&amp; this will also be quoted');


$html = HTML.new ~ '& more quoting';

dd $html;

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

put $html.Str;

# OUTPUT: &amp; more quoting

License

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

You can’t perform that action at this time.