NAME

Template::Caribou::Tags::HTML::Extended - custom HTML tags optimized for DWIMery

VERSION

version 1.2.2

SYNOPSIS

package MyTemplate;

use Moose;

use Template::Caribou::Tags::HTML;
use Template::Caribou::Tags::HTML::Extended;

with 'Template::Caribou';

template 'page' => sub {
    html {
        head { 
            css q{
                color: magenta;
            };
        };
        body {
            markdown q{Ain't Markdown **grand**?};
            
            anchor "http://foo.com" => sub {
                image 'http://foo.com/bar.jpg', alt => 'Foo logo';
            };
        }

    }
};

DESCRIPTION

Whereas Template::Caribou::Tags::HTML offers straight function equivalents to their HTML tags, this module provides a more DWIM interface, and shortcut for often used patterns.

doctype $type

doctype 'html5';
# <!DOCTYPE html>

Prints the doctype declaration for the given type.

For the moment, only html 5 (or html5) is supported as a type.

favicon $url

Generates a favicon link tag.

favicon 'my_icon.png';
# <link rel="shortcut icon" href="my_icon.png" />

submit $value, %attr

submit 'foo';
# <input type="submit" value="foo" />

Shortcut for

input { attr type => submit, value => $value, %attr; }

less $script

Compiles the LESS script into CSS. Requires CSS::LESSp.

javascript $script

javascript q{ console.log( "Hello there!" ) };
# <script type="text/javascript">console.log( "Hello there!" )</script>

Shortcut for

<script type="text/javascript>$script</script>

javascript_include $url

Shortcut for

<script type="text/javascript" src="http://..."> </script>

css_include $url, %args

css_include 'public/bootstrap/css/bootstrap.min.css', media => 'screen';
# <link href="public/bootstrap/css/bootstrap.min.css" rel="stylesheet"
#       media="screen" />

css $text

Wraps the $text in a style element.

<style type="text/css">$text</style>

anchor $url, $inner

Shortcut for <a>. $inner can be either a string, or a subref.

anchor 'http://foo.com' => 'linkie';

is equivalent to

a {
    attr href => 'http://foo.com';
    'linkie';
}

image $src, %attr

image 'kitten.jpg';
# <img src="kitten.jpg" />

Shortcut for <img>.

markdown $text

Converts the markdown $text into its html equivalent.

Uses Text::MultiMarkdown.

AUTHOR

Yanick Champoux <yanick@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2023 by Yanick Champoux.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.