NAME
Data::Org::Template - template engine that plays well with iterators
VERSION
Version 0.04
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 ]]
.
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
.
REGISTERING A DATA GETTER
A template can be expressed by providing a data getter (a map from name to value) at expression time, but you can also register a default data getter against the template when you define it, for convenience.
data_getter ([data getter])
Sets or gets the current data getter for the template. If you pass one or more data getters (which can be a data getter object, a hashref, or an arrayref of other data getters) then each will be checked in sequence.
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:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
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.