Author image Michael Roberts
and 1 contributors

NAME

Data::Org::Template - template engine that plays well with iterators

VERSION

Version 0.02

SYNOPSIS

CREATING A TEMPLATE

new (text, [start, end])

Aside from the text to be loaded as a template, you can also provide delimiters for the fields in start and end. If only one string is provided, it is assumed to encode both start *and* end, and will be split in equal halves. The default delimiters are [[ and ]].

ANALYZING A TEMPLATE AND REGISTERING A DATA GETTER AND CUSTOM TRANSDUCERS

Once a template has been parsed, we can scan it for the data fields it expects from its data source and for the transducers it uses.

data_requested ()

transducers_requested ()

register_transducer ()

data_getter ([data getter])

Sets or gets the current data getter for the template.

check_data_requested ()

Checks the data requested against the current data getter, if any. Returns a list of values not available in the getter.

EXPRESSING A TEMPLATE

A template can be either fully or partly expressed. If it's only partly expressed, the result is a new template with some of the fields replaced with values, and others left intact.

If the template uses transducers we don't recognize, it will croak with an appropriate warning.

iter([data getter])

Starts a token iterator from the template. A token stream, the way I do it, is an iterator for which each value returned is either a string (plain text) or a token. A token is an arrayref of [type, value, <arbitrary stuff>], so extracting the value is easy.

If no data getter is specified, uses the one registered in the template. If none is registered, croaks because you can't express a template on nothing, can you?

_compile_token_stream ($stream)

This is just a helper function - NOT object-oriented in nature (the initial underscore might help you - and me - remember that).

text()

Compiles the iterator into an output string for you, using _compile_token_stream.

AUTHOR

Michael Roberts, <michael at vivtek.com>

BUGS

Please report any bugs or feature requests to bug-data-org at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Org-Template. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Data::Org::Template

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2020 Michael Roberts.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.