summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3packages/xtemplate
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-08-18 23:13:18 +0000
committerKarl Berry <karl@freefriends.org>2011-08-18 23:13:18 +0000
commit6cff5abeab9bf94a6cabb2cbdba9d458c9727b73 (patch)
tree63ae3a16468aeb265f4b95d5eacb1deec963ee64 /Master/texmf-dist/source/latex/l3packages/xtemplate
parenteae5d19d439ded67f5535d315a8983939733b548 (diff)
l3packages 2607 (17aug11)
git-svn-id: svn://tug.org/texlive/trunk@23597 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3packages/xtemplate')
-rw-r--r--Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx114
1 files changed, 52 insertions, 62 deletions
diff --git a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx
index 3d2380d28aa..a75943d993f 100644
--- a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx
+++ b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx
@@ -40,7 +40,7 @@
%
%<*driver|package>
\RequirePackage{expl3}
-\GetIdInfo$Id: xtemplate.dtx 2535 2011-08-10 18:26:57Z joseph $
+\GetIdInfo$Id: xtemplate.dtx 2607 2011-08-17 16:43:25Z joseph $
{L3 Experimental prototype document functions}
%</driver|package>
%<*driver>
@@ -112,12 +112,6 @@
% \pkg{xtemplate} also makes it easier for \LaTeX{} programmers to provide
% their own customisations on top of a pre-existing class.
%
-% The idea behind the template module is to cleanly separate the three
-% layers, so that document authors who are not programmers can easily
-% change the design of their documents. Templates also make it easier
-% for \LaTeX{} programmers to provide their own customisations on top of
-% a pre-existing class.
-%
% \section{What is a document?}
%
% Besides the textual content of the words themselves, the source file
@@ -158,7 +152,7 @@
% By formally declaring documents to be composed of mark-up elements
% grouped into objects, which are interpreted and typeset with a set of
% templates, each of which has one or more instances with which to
-% compose each and every semantic unit of the text, there can be clean
+% compose each and every semantic unit of the text, we can cleanly
% separate the components of document construction.
%
% All of the structures provided by the template system are global,
@@ -234,7 +228,7 @@
% with the exception of |,|, |=| and \verb*| |. The recommended form
% for key names is to use lower case letters, with dashes to separate
% out different parts. Spaces are ignored in key names, so they can be
-% included are missed out at will. Each \meta{key} must have a
+% included or missed out at will. Each \meta{key} must have a
% \meta{key type}, which defined the type of input that the \meta{key}
% requires. A full list of key types is given in
% Table~\ref{tab:key-types}. Each key may have a \meta{default}
@@ -253,7 +247,7 @@
% & A list of pre-defined \meta{choices} \\
% code
% & Generalised key type: use |#1| as the input to the key \\
-% commalist & A comma-separated \\
+% commalist & A comma-separated list \\
% function\Arg{$N$}
% & A function definition with $N$ arguments
% ($N$ from $0$ to $9$) \\
@@ -664,7 +658,7 @@
%
% A check to make sure that \pkg{expl3} is not too old
% \begin{macrocode}
-\@ifpackagelater { expl3 } { 2011/08/13 }
+\@ifpackagelater { expl3 } { 2011/08/17 }
{ }
{
\PackageError { xtemplate } { Support~package~l3kernel~too~old. }
@@ -850,6 +844,18 @@
% \end{macrocode}
% \end{variable}
%
+% \subsection{Variant of prop functions}
+%
+% \begin{macro}[TF]{\prop_get:NoN}
+% In some cases, we need to expand the key, and get the corresponding
+% value in a property list if it exists.
+% \begin{macrocode}
+\cs_generate_variant:Nn \prop_get:NnNTF { No }
+\cs_generate_variant:Nn \prop_get:NnNT { No }
+\cs_generate_variant:Nn \prop_get:NnNF { No }
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Testing existence and validity}
%
% There are a number of checks needed for either the existence of
@@ -1506,13 +1512,10 @@
\xtemplate_store_vars:n { #1 / #2 }
\clist_clear:N \l_xtemplate_restrict_clist
\xtemplate_store_restrictions:n { #1 / #2 }
- \prop_if_empty:NF \l_xtemplate_keytypes_prop
+ \prop_map_inline:Nn \l_xtemplate_keytypes_prop
{
- \prop_map_inline:Nn \l_xtemplate_keytypes_prop
- {
- \msg_error:nnxxx { xtemplate } { key-not-implemented }
- {##1} {#2} {#1}
- }
+ \msg_error:nnxxx { xtemplate } { key-not-implemented }
+ {##1} {#2} {#1}
}
}
% \end{macrocode}
@@ -1537,10 +1540,11 @@
{
\tl_set:Nx \l_xtemplate_key_name_tl { \tl_to_str:n {#1} }
\tl_remove_all:Nn \l_xtemplate_key_name_tl { ~ }
- \prop_if_in:NoTF \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl
+ \prop_get:NoNTF
+ \l_xtemplate_keytypes_prop
+ \l_xtemplate_key_name_tl
+ \l_xtemplate_keytype_tl
{
- \prop_get:NoN \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl
- \l_xtemplate_keytype_tl
\xtemplate_split_keytype_arg:o \l_xtemplate_keytype_tl
\xtemplate_parse_vars_elt_aux:n {#2}
\prop_del:NV \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl
@@ -1634,7 +1638,8 @@
\keyval_parse:NNn
\xtemplate_implement_choice_elt:n \xtemplate_implement_choice_elt:nn
{#1}
- \prop_if_in:NoT \l_xtemplate_values_prop \l_xtemplate_key_name_tl
+ \prop_get:NoNT \l_xtemplate_values_prop \l_xtemplate_key_name_tl
+ \l_xtemplate_tmp_tl
{ \xtemplate_implement_choices_default: }
\clist_if_empty:NF \l_xtemplate_tmp_clist
{
@@ -1651,8 +1656,6 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xtemplate_implement_choices_default:
{
- \prop_get:NoN \l_xtemplate_values_prop \l_xtemplate_key_name_tl
- \l_xtemplate_tmp_tl
\tl_set:Nx \l_xtemplate_tmp_tl
{ \l_xtemplate_key_name_tl \c_space_tl \l_xtemplate_tmp_tl }
\prop_if_in:NoF \l_xtemplate_vars_prop \l_xtemplate_tmp_tl
@@ -1700,7 +1703,7 @@
}
{
\clist_if_in:NnTF \l_xtemplate_tmp_clist {#1}
- { \clist_remove_element:Nn \l_xtemplate_tmp_clist {#1} }
+ { \clist_remove_all:Nn \l_xtemplate_tmp_clist {#1} }
{
\prop_get:NoN \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl
\l_xtemplate_tmp_tl
@@ -1799,8 +1802,7 @@
% \end{macro}
%
% \begin{macro}{\xtemplate_parse_values_elt:nn}
-% \begin{macro}[aux]{\xtemplate_parse_values_elt_aux:nn}
-% \begin{macro}[aux]{\xtemplate_parse_values_elt_aux:on}
+% \begin{macro}[aux]{\xtemplate_parse_values_elt_aux:n}
% To store the value, find the keytype then call the saving function.
% These need the current key name saved as \cs{l_xtemplate_key_name_tl}.
% When a template is being restricted, the setting code will be
@@ -1810,36 +1812,31 @@
{
\tl_set:Nx \l_xtemplate_key_name_tl { \tl_to_str:n {#1} }
\tl_remove_all:Nn \l_xtemplate_key_name_tl { ~ }
- \prop_if_in:NoTF \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl
+ \prop_get:NoNTF \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl
+ \l_xtemplate_tmp_tl
{
\bool_if:NTF \l_xtemplate_restrict_bool
{
\clist_if_in:NoF \l_xtemplate_restrict_clist
\l_xtemplate_key_name_tl
- {
- \xtemplate_parse_values_elt_aux:on
- \l_xtemplate_key_name_tl {#2}
- }
+ { \xtemplate_parse_values_elt_aux:n {#2} }
}
- { \xtemplate_parse_values_elt_aux:on \l_xtemplate_key_name_tl {#2} }
+ { \xtemplate_parse_values_elt_aux:n {#2} }
}
{
\msg_error:nnx { xtemplate } { unknown-key }
{ \l_xtemplate_key_name_tl }
}
}
-\cs_new_protected:Npn \xtemplate_parse_values_elt_aux:nn #1#2
+\cs_new_protected:Npn \xtemplate_parse_values_elt_aux:n #1
{
- \clist_put_right:Nn \l_xtemplate_restrict_clist {#1}
- \prop_get:NnN \l_xtemplate_keytypes_prop {#1} \l_xtemplate_tmp_tl
+ \clist_put_right:No \l_xtemplate_restrict_clist \l_xtemplate_key_name_tl
\xtemplate_split_keytype_arg:o \l_xtemplate_tmp_tl
- \use:c { xtemplate_store_value_ \l_xtemplate_keytype_tl :n } {#2}
+ \use:c { xtemplate_store_value_ \l_xtemplate_keytype_tl :n } {#1}
}
-\cs_generate_variant:Nn \xtemplate_parse_values_elt_aux:nn { o }
% \end{macrocode}
% \end{macro}
% \end{macro}
-% \end{macro}
%
% \begin{macro}{\xtemplate_set_template_eq:nn}
% To copy a template, each of the lists plus the code has to be copied
@@ -1972,12 +1969,10 @@
% \begin{macrocode}
\cs_new_protected:Npn \xtemplate_convert_to_assignments_aux:nn #1#2
{
- \prop_if_in:NnT \l_xtemplate_values_prop {#1}
+ \prop_get:NnNT \l_xtemplate_values_prop {#1} \l_xtemplate_value_tl
{
- \prop_if_in:NnTF \l_xtemplate_vars_prop {#1}
+ \prop_get:NnNTF \l_xtemplate_vars_prop {#1} \l_xtemplate_var_tl
{
- \prop_get:NnN \l_xtemplate_values_prop {#1} \l_xtemplate_value_tl
- \prop_get:NnN \l_xtemplate_vars_prop {#1} \l_xtemplate_var_tl
\xtemplate_split_keytype_arg:n {#2}
\str_if_eq:onF \l_xtemplate_keytype_tl { choice }
{
@@ -2078,15 +2073,11 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \xtemplate_assign_choice:
{
- \tl_set:Nx \l_xtemplate_tmp_tl
+ \xtemplate_assign_choice_aux:xF
{ \l_xtemplate_key_name_tl \c_space_tl \l_xtemplate_value_tl }
- \prop_if_in:NoTF \l_xtemplate_vars_prop \l_xtemplate_tmp_tl
- { \xtemplate_assign_choice_aux:o \l_xtemplate_tmp_tl }
{
- \tl_set:Nx \l_xtemplate_tmp_tl
+ \xtemplate_assign_choice_aux:xF
{ \l_xtemplate_key_name_tl \c_space_tl unknown }
- \prop_if_in:NoTF \l_xtemplate_vars_prop \l_xtemplate_tmp_tl
- { \xtemplate_assign_choice_aux:o \l_xtemplate_tmp_tl }
{
\prop_get:NoN \l_xtemplate_keytypes_prop \l_xtemplate_key_name_tl
\l_xtemplate_tmp_tl
@@ -2097,12 +2088,15 @@
}
}
}
-\cs_new_protected:Npn \xtemplate_assign_choice_aux:n #1
+\cs_new_protected_nopar:Npn \xtemplate_assign_choice_aux:nF #1
{
- \prop_get:NnN \l_xtemplate_vars_prop {#1} \l_xtemplate_tmp_tl
- \tl_put_right:No \l_xtemplate_assignments_tl \l_xtemplate_tmp_tl
+ \prop_get:NnNTF
+ \l_xtemplate_vars_prop
+ {#1}
+ \l_xtemplate_tmp_tl
+ { \tl_put_right:No \l_xtemplate_assignments_tl \l_xtemplate_tmp_tl }
}
-\cs_generate_variant:Nn \xtemplate_assign_choice_aux:n { o }
+\cs_generate_variant:Nn \xtemplate_assign_choice_aux:nF { x }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -2287,11 +2281,10 @@
{
\tl_set:Nx \l_xtemplate_tmp_tl { \tl_to_str:n {#1} }
\tl_remove_all:Nn \l_xtemplate_key_name_tl { ~ }
- \prop_if_in:NoTF \l_xtemplate_vars_prop \l_xtemplate_tmp_tl
- {
- \prop_get:NoN \l_xtemplate_vars_prop \l_xtemplate_tmp_tl
- \l_xtemplate_value_tl
- }
+ \prop_get:NoNF
+ \l_xtemplate_vars_prop
+ \l_xtemplate_tmp_tl
+ \l_xtemplate_value_tl
{
\msg_error:nnx { xtemplate } { unknown-attribute }
{ \l_xtemplate_tmp_tl }
@@ -2367,11 +2360,8 @@
% \begin{macrocode}
\cs_new_protected:Npn \xtemplate_get_collection:n #1
{
- \prop_if_in:NnTF \l_xtemplate_collections_prop {#1}
- {
- \prop_get:NnN \l_xtemplate_collections_prop {#1}
- \l_xtemplate_collection_tl
- }
+ \prop_get:NnNF \l_xtemplate_collections_prop {#1}
+ \l_xtemplate_collection_tl
{ \tl_clear:N \l_xtemplate_collection_tl }
}
% \end{macrocode}