| 1 |
%% |
| 2 |
%% This is file `xtemplate-2023-10-10.sty', generated from |
| 3 |
%% xtemplate.dtx (with options: `package' on 2023-11-14) |
| 4 |
%% then adapted and frozen for compatibility. Development of |
| 5 |
%% xtemplate.dtx will continue in the LaTeX2e kernel as lttemplates.dtx. |
| 6 |
%% |
| 7 |
%% Copyright (C) 2011-2023 The LaTeX Project |
| 8 |
%% |
| 9 |
%% It may be distributed and/or modified under the conditions of |
| 10 |
%% the LaTeX Project Public License (LPPL), either version 1.3c of |
| 11 |
%% this license or (at your option) any later version. The latest |
| 12 |
%% version of this license is in the file: |
| 13 |
%% |
| 14 |
%% http://www.latex-project.org/lppl.txt |
| 15 |
%% |
| 16 |
%% This file is part of the "l3packages bundle" (The Work in LPPL) |
| 17 |
%% and all files in that bundle must be distributed together. |
| 18 |
%% |
| 19 |
%% File: xtemplate.dtx |
| 20 |
\RequirePackage{expl3}[2018/02/21] |
| 21 |
\@ifpackagelater{expl3}{2018/02/21} |
| 22 |
{} |
| 23 |
{% |
| 24 |
\PackageError{xtemplate}{Support package l3kernel too old} |
| 25 |
{% |
| 26 |
Please install an up to date version of l3kernel\MessageBreak |
| 27 |
using your TeX package manager or from CTAN.\MessageBreak |
| 28 |
\MessageBreak |
| 29 |
Loading xtemplate will abort!% |
| 30 |
}% |
| 31 |
\endinput |
| 32 |
} |
| 33 |
\ProvidesExplPackage{xtemplate}{2023-10-10}{} |
| 34 |
{L3 Experimental prototype document functions} |
| 35 |
\tl_const:Nn \c__xtemplate_code_root_tl { template~code~>~ } |
| 36 |
\tl_const:Nn \c__xtemplate_defaults_root_tl { template~defaults~>~ } |
| 37 |
\tl_const:Nn \c__xtemplate_instances_root_tl { template~instance~>~ } |
| 38 |
\tl_const:Nn \c__xtemplate_keytypes_root_tl { template~key~types~>~ } |
| 39 |
\tl_const:Nn \c__xtemplate_key_order_root_tl { template~key~order~>~ } |
| 40 |
\tl_const:Nn \c__xtemplate_restrict_root_tl { template~restrictions~>~ } |
| 41 |
\tl_const:Nn \c__xtemplate_values_root_tl { template~values~>~ } |
| 42 |
\tl_const:Nn \c__xtemplate_vars_root_tl { template~vars~>~ } |
| 43 |
\seq_const_from_clist:Nn \c__xtemplate_keytypes_arg_seq |
| 44 |
{ choice , function , instance } |
| 45 |
\prop_new:N \g__xtemplate_object_type_prop |
| 46 |
\tl_new:N \l__xtemplate_assignments_tl |
| 47 |
\tl_new:N \l__xtemplate_collection_tl |
| 48 |
\prop_new:N \l__xtemplate_collections_prop |
| 49 |
\tl_new:N \l__xtemplate_default_tl |
| 50 |
\bool_new:N \l__xtemplate_error_bool |
| 51 |
\bool_new:N \l__xtemplate_global_bool |
| 52 |
\bool_new:N \l__xtemplate_restrict_bool |
| 53 |
\clist_new:N \l__xtemplate_restrict_clist |
| 54 |
\tl_new:N \l__xtemplate_key_name_tl |
| 55 |
\tl_new:N \l__xtemplate_keytype_tl |
| 56 |
\tl_new:N \l__xtemplate_keytype_arg_tl |
| 57 |
\tl_new:N \l__xtemplate_value_tl |
| 58 |
\tl_new:N \l__xtemplate_var_tl |
| 59 |
\prop_new:N \l__xtemplate_keytypes_prop |
| 60 |
\seq_new:N \l__xtemplate_key_order_seq |
| 61 |
\prop_new:N \l__xtemplate_values_prop |
| 62 |
\prop_new:N \l__xtemplate_vars_prop |
| 63 |
\clist_new:N \l__xtemplate_tmp_clist |
| 64 |
\dim_new:N \l__xtemplate_tmp_dim |
| 65 |
\int_new:N \l__xtemplate_tmp_int |
| 66 |
\muskip_new:N \l__xtemplate_tmp_muskip |
| 67 |
\skip_new:N \l__xtemplate_tmp_skip |
| 68 |
\tl_new:N \l__xtemplate_tmp_tl |
| 69 |
\scan_new:N \s__xtemplate_mark |
| 70 |
\scan_new:N \s__xtemplate_stop |
| 71 |
\quark_new:N \q__xtemplate_nil |
| 72 |
\__kernel_quark_new_conditional:Nn \__xtemplate_quark_if_nil:N { F } |
| 73 |
\cs_generate_variant:Nn \prop_get:NnNTF { No } |
| 74 |
\cs_generate_variant:Nn \prop_get:NnNT { No } |
| 75 |
\cs_generate_variant:Nn \prop_get:NnNF { No } |
| 76 |
\cs_new_protected:Npn \__xtemplate_execute_if_arg_agree:nnT #1#2#3 |
| 77 |
{ |
| 78 |
\prop_get:NnN \g__xtemplate_object_type_prop {#1} \l__xtemplate_tmp_tl |
| 79 |
\int_compare:nNnTF {#2} = \l__xtemplate_tmp_tl |
| 80 |
{#3} |
| 81 |
{ |
| 82 |
\msg_error:nneee { xtemplate } |
| 83 |
{ argument-number-mismatch } {#1} { \l__xtemplate_tmp_tl } {#2} |
| 84 |
} |
| 85 |
} |
| 86 |
\cs_new_protected:Npn \__xtemplate_execute_if_code_exist:nnT #1#2#3 |
| 87 |
{ |
| 88 |
\cs_if_exist:cTF { \c__xtemplate_code_root_tl #1 / #2 } |
| 89 |
{#3} |
| 90 |
{ |
| 91 |
\msg_error:nnee { xtemplate } { no-template-code } |
| 92 |
{#1} {#2} |
| 93 |
} |
| 94 |
} |
| 95 |
\cs_new_protected:Npn \__xtemplate_execute_if_keytype_exist:nT #1#2 |
| 96 |
{ |
| 97 |
\cs_if_exist:cTF { __xtemplate_store_value_ #1 :n } |
| 98 |
{#2} |
| 99 |
{ \msg_error:nne { xtemplate } { unknown-keytype } {#1} } |
| 100 |
} |
| 101 |
\cs_generate_variant:Nn \__xtemplate_execute_if_keytype_exist:nT { o } |
| 102 |
\cs_new_protected:Npn \__xtemplate_execute_if_type_exist:nT #1#2 |
| 103 |
{ |
| 104 |
\prop_if_in:NnTF \g__xtemplate_object_type_prop {#1} |
| 105 |
{#2} |
| 106 |
{ \msg_error:nne { xtemplate } { unknown-object-type } {#1} } |
| 107 |
} |
| 108 |
\cs_new_protected:Npn \__xtemplate_if_keys_exist:nnT #1#2#3 |
| 109 |
{ |
| 110 |
\cs_if_exist:cTF { \c__xtemplate_keytypes_root_tl #1 / #2 } |
| 111 |
{#3} |
| 112 |
{ |
| 113 |
\msg_error:nnee { xtemplate } { unknown-template } |
| 114 |
{#1} {#2} |
| 115 |
} |
| 116 |
} |
| 117 |
\prg_new_conditional:Npnn \__xtemplate_if_key_value:n #1 { T , F , TF } |
| 118 |
{ |
| 119 |
\str_if_eq:noTF { \KeyValue } { \tl_head:w #1 \q_nil \q_stop } |
| 120 |
{ \prg_return_true: } |
| 121 |
{ \prg_return_false: } |
| 122 |
} |
| 123 |
\cs_generate_variant:Nn \__xtemplate_if_key_value:nT { o } |
| 124 |
\cs_generate_variant:Nn \__xtemplate_if_key_value:nF { o } |
| 125 |
\cs_generate_variant:Nn \__xtemplate_if_key_value:nTF { o } |
| 126 |
\prg_new_conditional:Npnn \__xtemplate_if_instance_exist:nnn #1#2#3 |
| 127 |
{ T, F, TF } |
| 128 |
{ |
| 129 |
\cs_if_exist:cTF { \c__xtemplate_instances_root_tl #1 / #2 / #3 } |
| 130 |
{ \prg_return_true: } |
| 131 |
{ \prg_return_false: } |
| 132 |
} |
| 133 |
\prg_new_conditional:Npnn \__xtemplate_if_use_template:n #1 { TF } |
| 134 |
{ |
| 135 |
\str_if_eq:noTF { \UseTemplate } { \tl_head:w #1 \q_nil \q_stop } |
| 136 |
{ \prg_return_true: } |
| 137 |
{ \prg_return_false: } |
| 138 |
} |
| 139 |
\cs_new_protected:Npn \__xtemplate_store_defaults:n #1 |
| 140 |
{ |
| 141 |
\prop_gclear_new:c { \c__xtemplate_defaults_root_tl #1 } |
| 142 |
\prop_gset_eq:cN { \c__xtemplate_defaults_root_tl #1 } |
| 143 |
\l__xtemplate_values_prop |
| 144 |
} |
| 145 |
\cs_new_protected:Npn \__xtemplate_store_keytypes:n #1 |
| 146 |
{ |
| 147 |
\prop_gclear_new:c { \c__xtemplate_keytypes_root_tl #1 } |
| 148 |
\prop_gset_eq:cN { \c__xtemplate_keytypes_root_tl #1 } |
| 149 |
\l__xtemplate_keytypes_prop |
| 150 |
\seq_gclear_new:c { \c__xtemplate_key_order_root_tl #1 } |
| 151 |
\seq_gset_eq:cN { \c__xtemplate_key_order_root_tl #1 } |
| 152 |
\l__xtemplate_key_order_seq |
| 153 |
} |
| 154 |
\cs_new_protected:Npn \__xtemplate_store_values:n #1 |
| 155 |
{ |
| 156 |
\prop_clear_new:c { \c__xtemplate_values_root_tl #1 } |
| 157 |
\prop_set_eq:cN { \c__xtemplate_values_root_tl #1 } |
| 158 |
\l__xtemplate_values_prop |
| 159 |
} |
| 160 |
\cs_new_protected:Npn \__xtemplate_store_restrictions:n #1 |
| 161 |
{ |
| 162 |
\clist_gclear_new:c { \c__xtemplate_restrict_root_tl #1 } |
| 163 |
\clist_gset_eq:cN { \c__xtemplate_restrict_root_tl #1 } |
| 164 |
\l__xtemplate_restrict_clist |
| 165 |
} |
| 166 |
\cs_new_protected:Npn \__xtemplate_store_vars:n #1 |
| 167 |
{ |
| 168 |
\prop_gclear_new:c { \c__xtemplate_vars_root_tl #1 } |
| 169 |
\prop_gset_eq:cN { \c__xtemplate_vars_root_tl #1 } |
| 170 |
\l__xtemplate_vars_prop |
| 171 |
} |
| 172 |
\cs_new_protected:Npn \__xtemplate_recover_defaults:n #1 |
| 173 |
{ |
| 174 |
\prop_if_exist:cTF |
| 175 |
{ \c__xtemplate_defaults_root_tl #1 } |
| 176 |
{ |
| 177 |
\prop_set_eq:Nc \l__xtemplate_values_prop |
| 178 |
{ \c__xtemplate_defaults_root_tl #1 } |
| 179 |
} |
| 180 |
{ \prop_clear:N \l__xtemplate_values_prop } |
| 181 |
} |
| 182 |
\cs_new_protected:Npn \__xtemplate_recover_keytypes:n #1 |
| 183 |
{ |
| 184 |
\prop_if_exist:cTF |
| 185 |
{ \c__xtemplate_keytypes_root_tl #1 } |
| 186 |
{ |
| 187 |
\prop_set_eq:Nc \l__xtemplate_keytypes_prop |
| 188 |
{ \c__xtemplate_keytypes_root_tl #1 } |
| 189 |
} |
| 190 |
{ \prop_clear:N \l__xtemplate_keytypes_prop } |
| 191 |
\seq_if_exist:cTF { \c__xtemplate_key_order_root_tl #1 } |
| 192 |
{ |
| 193 |
\seq_set_eq:Nc \l__xtemplate_key_order_seq |
| 194 |
{ \c__xtemplate_key_order_root_tl #1 } |
| 195 |
} |
| 196 |
{ \seq_clear:N \l__xtemplate_key_order_seq } |
| 197 |
} |
| 198 |
\cs_new_protected:Npn \__xtemplate_recover_restrictions:n #1 |
| 199 |
{ |
| 200 |
\clist_if_exist:cTF |
| 201 |
{ \c__xtemplate_restrict_root_tl #1 } |
| 202 |
{ |
| 203 |
\clist_set_eq:Nc \l__xtemplate_restrict_clist |
| 204 |
{ \c__xtemplate_restrict_root_tl #1 } |
| 205 |
} |
| 206 |
{ \clist_clear:N \l__xtemplate_restrict_clist } |
| 207 |
} |
| 208 |
\cs_new_protected:Npn \__xtemplate_recover_values:n #1 |
| 209 |
{ |
| 210 |
\prop_if_exist:cTF |
| 211 |
{ \c__xtemplate_values_root_tl #1 } |
| 212 |
{ |
| 213 |
\prop_set_eq:Nc \l__xtemplate_values_prop |
| 214 |
{ \c__xtemplate_values_root_tl #1 } |
| 215 |
} |
| 216 |
{ \prop_clear:N \l__xtemplate_values_prop } |
| 217 |
} |
| 218 |
\cs_new_protected:Npn \__xtemplate_recover_vars:n #1 |
| 219 |
{ |
| 220 |
\prop_if_exist:cTF |
| 221 |
{ \c__xtemplate_vars_root_tl #1 } |
| 222 |
{ |
| 223 |
\prop_set_eq:Nc \l__xtemplate_vars_prop |
| 224 |
{ \c__xtemplate_vars_root_tl #1 } |
| 225 |
} |
| 226 |
{ \prop_clear:N \l__xtemplate_vars_prop } |
| 227 |
} |
| 228 |
\cs_new_protected:Npn \__xtemplate_declare_object_type:nn #1#2 |
| 229 |
{ |
| 230 |
\int_set:Nn \l__xtemplate_tmp_int {#2} |
| 231 |
\int_compare:nTF { 0 <= \l__xtemplate_tmp_int <= 9 } |
| 232 |
{ |
| 233 |
\msg_info:nnnV { xtemplate } { declare-object-type } |
| 234 |
{#1} \l__xtemplate_tmp_int |
| 235 |
\prop_gput:NnV \g__xtemplate_object_type_prop {#1} |
| 236 |
\l__xtemplate_tmp_int |
| 237 |
} |
| 238 |
{ |
| 239 |
\msg_error:nnee { xtemplate } { bad-number-of-arguments } |
| 240 |
{#1} { \exp_not:V \l__xtemplate_tmp_int } |
| 241 |
} |
| 242 |
} |
| 243 |
\cs_new_protected:Npn \__xtemplate_declare_template_keys:nnnn #1#2#3#4 |
| 244 |
{ |
| 245 |
\__xtemplate_execute_if_type_exist:nT {#1} |
| 246 |
{ |
| 247 |
\__xtemplate_execute_if_arg_agree:nnT {#1} {#3} |
| 248 |
{ |
| 249 |
\prop_clear:N \l__xtemplate_values_prop |
| 250 |
\prop_clear:N \l__xtemplate_keytypes_prop |
| 251 |
\seq_clear:N \l__xtemplate_key_order_seq |
| 252 |
\keyval_parse:NNn |
| 253 |
\__xtemplate_parse_keys_elt:n \__xtemplate_parse_keys_elt:nn {#4} |
| 254 |
\__xtemplate_store_defaults:n { #1 / #2 } |
| 255 |
\__xtemplate_store_keytypes:n { #1 / #2 } |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 259 |
\cs_new_protected:Npn \__xtemplate_parse_keys_elt:n #1 |
| 260 |
{ |
| 261 |
\__xtemplate_split_keytype:n {#1} |
| 262 |
\bool_if:NF \l__xtemplate_error_bool |
| 263 |
{ |
| 264 |
\__xtemplate_execute_if_keytype_exist:oT \l__xtemplate_keytype_tl |
| 265 |
{ |
| 266 |
\seq_map_function:NN \c__xtemplate_keytypes_arg_seq |
| 267 |
\__xtemplate_parse_keys_elt_aux:n |
| 268 |
\bool_if:NF \l__xtemplate_error_bool |
| 269 |
{ |
| 270 |
\seq_if_in:NoTF \l__xtemplate_key_order_seq |
| 271 |
\l__xtemplate_key_name_tl |
| 272 |
{ |
| 273 |
\msg_error:nne { xtemplate } |
| 274 |
{ duplicate-key-interface } |
| 275 |
{ \l__xtemplate_key_name_tl } |
| 276 |
} |
| 277 |
{ \__xtemplate_parse_keys_elt_aux: } |
| 278 |
} |
| 279 |
} |
| 280 |
} |
| 281 |
} |
| 282 |
\cs_new_protected:Npn \__xtemplate_parse_keys_elt_aux:n #1 |
| 283 |
{ |
| 284 |
\str_if_eq:onT \l__xtemplate_keytype_tl {#1} |
| 285 |
{ |
| 286 |
\tl_if_empty:NT \l__xtemplate_keytype_arg_tl |
| 287 |
{ |
| 288 |
\msg_error:nne { xtemplate } |
| 289 |
{ keytype-requires-argument } {#1} |
| 290 |
\bool_set_true:N \l__xtemplate_error_bool |
| 291 |
\seq_map_break: |
| 292 |
} |
| 293 |
} |
| 294 |
} |
| 295 |
\cs_new:Npn \__xtemplate_parse_keys_elt_aux: |
| 296 |
{ |
| 297 |
\tl_set:Ne \l__xtemplate_tmp_tl |
| 298 |
{ |
| 299 |
\l__xtemplate_keytype_tl |
| 300 |
\tl_if_empty:NF \l__xtemplate_keytype_arg_tl |
| 301 |
{ { \l__xtemplate_keytype_arg_tl } } |
| 302 |
} |
| 303 |
\prop_put:Noo \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl |
| 304 |
\l__xtemplate_tmp_tl |
| 305 |
\seq_put_right:No \l__xtemplate_key_order_seq \l__xtemplate_key_name_tl |
| 306 |
\str_if_eq:onT \l__xtemplate_keytype_tl { choice } |
| 307 |
{ |
| 308 |
\exp_args:No \clist_if_in:nnT \l__xtemplate_keytype_arg_tl { unknown } |
| 309 |
{ \msg_error:nn { xtemplate } { choice-unknown-reserved } } |
| 310 |
} |
| 311 |
} |
| 312 |
\cs_new_protected:Npn \__xtemplate_parse_keys_elt:nn #1#2 |
| 313 |
{ |
| 314 |
\__xtemplate_parse_keys_elt:n {#1} |
| 315 |
\use:c { __xtemplate_store_value_ \l__xtemplate_keytype_tl :n } {#2} |
| 316 |
} |
| 317 |
\cs_new_protected:Npe \__xtemplate_split_keytype:n #1 |
| 318 |
{ |
| 319 |
\exp_not:N \bool_set_false:N \exp_not:N \l__xtemplate_error_bool |
| 320 |
\tl_set:Nn \exp_not:N \l__xtemplate_tmp_tl {#1} |
| 321 |
\tl_replace_all:Nnn \exp_not:N \l__xtemplate_tmp_tl { : } { \token_to_str:N : } |
| 322 |
\tl_if_in:onTF \exp_not:N \l__xtemplate_tmp_tl { \token_to_str:N : } |
| 323 |
{ |
| 324 |
\exp_not:n |
| 325 |
{ |
| 326 |
\tl_clear:N \l__xtemplate_key_name_tl |
| 327 |
\exp_after:wN \__xtemplate_split_keytype_aux:w |
| 328 |
\l__xtemplate_tmp_tl \s__xtemplate_stop |
| 329 |
} |
| 330 |
} |
| 331 |
{ |
| 332 |
\exp_not:N \bool_set_true:N \exp_not:N \l__xtemplate_error_bool |
| 333 |
\msg_error:nne { xtemplate } { missing-keytype } {#1} |
| 334 |
} |
| 335 |
} |
| 336 |
\use:e |
| 337 |
{ |
| 338 |
\cs_new_protected:Npn \exp_not:N \__xtemplate_split_keytype_aux:w |
| 339 |
#1 \token_to_str:N : #2 \s__xtemplate_stop |
| 340 |
{ |
| 341 |
\tl_put_right:Ne \exp_not:N \l__xtemplate_key_name_tl |
| 342 |
{ |
| 343 |
\exp_not:N \tl_trim_spaces:e |
| 344 |
{ \exp_not:N \tl_to_str:n {#1} } |
| 345 |
} |
| 346 |
\tl_if_in:nnTF {#2} { \token_to_str:N : } |
| 347 |
{ |
| 348 |
\tl_put_right:Nn \exp_not:N \l__xtemplate_key_name_tl |
| 349 |
{ \token_to_str:N : } |
| 350 |
\exp_not:N \__xtemplate_split_keytype_aux:w #2 \s__xtemplate_stop |
| 351 |
} |
| 352 |
{ |
| 353 |
\exp_not:N \tl_if_empty:NTF \exp_not:N \l__xtemplate_key_name_tl |
| 354 |
{ |
| 355 |
\msg_error:nne { xtemplate } { empty-key-name } |
| 356 |
{ \token_to_str:N : #2 } |
| 357 |
} |
| 358 |
{ \exp_not:N \__xtemplate_split_keytype_arg:n {#2} } |
| 359 |
} |
| 360 |
} |
| 361 |
} |
| 362 |
\cs_new_protected:Npn \__xtemplate_split_keytype_arg:n #1 |
| 363 |
{ |
| 364 |
\tl_set:Ne \l__xtemplate_keytype_tl { \tl_trim_spaces:n {#1} } |
| 365 |
\tl_clear:N \l__xtemplate_keytype_arg_tl |
| 366 |
\cs_set_protected:Npn \__xtemplate_split_keytype_arg_aux:n ##1 |
| 367 |
{ |
| 368 |
\tl_if_in:nnT {#1} {##1} |
| 369 |
{ |
| 370 |
\cs_set:Npn \__xtemplate_split_keytype_arg_aux:w |
| 371 |
####1 ##1 ####2 \s__xtemplate_stop |
| 372 |
{ |
| 373 |
\tl_if_blank:nT {####1} |
| 374 |
{ |
| 375 |
\tl_set:Ne \l__xtemplate_keytype_tl |
| 376 |
{ \tl_trim_spaces:n {##1} } |
| 377 |
\tl_if_blank:nF {####2} |
| 378 |
{ |
| 379 |
\tl_set:Ne \l__xtemplate_keytype_arg_tl |
| 380 |
{ \use:n ####2 } |
| 381 |
} |
| 382 |
\seq_map_break: |
| 383 |
} |
| 384 |
} |
| 385 |
\__xtemplate_split_keytype_arg_aux:w #1 \s__xtemplate_stop |
| 386 |
} |
| 387 |
} |
| 388 |
\seq_map_function:NN \c__xtemplate_keytypes_arg_seq |
| 389 |
\__xtemplate_split_keytype_arg_aux:n |
| 390 |
} |
| 391 |
\cs_generate_variant:Nn \__xtemplate_split_keytype_arg:n { o } |
| 392 |
\cs_new:Npn \__xtemplate_split_keytype_arg_aux:n #1 { } |
| 393 |
\cs_new:Npn \__xtemplate_split_keytype_arg_aux:w #1 \s__xtemplate_stop { } |
| 394 |
\cs_new_protected:Npn \__xtemplate_store_value_boolean:n #1 |
| 395 |
{ \prop_put:Non \l__xtemplate_values_prop \l__xtemplate_key_name_tl {#1} } |
| 396 |
\cs_new_protected:Npn \__xtemplate_store_value:n #1 |
| 397 |
{ \prop_put:Non \l__xtemplate_values_prop \l__xtemplate_key_name_tl {#1} } |
| 398 |
\cs_new_eq:NN \__xtemplate_store_value_choice:n \__xtemplate_store_value:n |
| 399 |
\cs_new_eq:NN \__xtemplate_store_value_function:n \__xtemplate_store_value:n |
| 400 |
\cs_new_eq:NN \__xtemplate_store_value_instance:n \__xtemplate_store_value:n |
| 401 |
\cs_new_protected:Npn \__xtemplate_store_value_aux:Nn #1#2 |
| 402 |
{ \prop_put:Non \l__xtemplate_values_prop \l__xtemplate_key_name_tl {#2} } |
| 403 |
\cs_new_protected:Npn \__xtemplate_store_value_integer:n |
| 404 |
{ \__xtemplate_store_value_aux:Nn \int_eval:n } |
| 405 |
\cs_new_protected:Npn \__xtemplate_store_value_length:n |
| 406 |
{ \__xtemplate_store_value_aux:Nn \dim_eval:n } |
| 407 |
\cs_new_protected:Npn \__xtemplate_store_value_muskip:n |
| 408 |
{ \__xtemplate_store_value_aux:Nn \muskip_eval:n } |
| 409 |
\cs_new_protected:Npn \__xtemplate_store_value_real:n |
| 410 |
{ \__xtemplate_store_value_aux:Nn \fp_eval:n } |
| 411 |
\cs_new_protected:Npn \__xtemplate_store_value_skip:n |
| 412 |
{ \__xtemplate_store_value_aux:Nn \skip_eval:n } |
| 413 |
\cs_new_protected:Npn \__xtemplate_store_value_tokenlist:n |
| 414 |
{ \__xtemplate_store_value_aux:Nn \use:n } |
| 415 |
\cs_new_eq:NN \__xtemplate_store_value_commalist:n \__xtemplate_store_value_tokenlist:n |
| 416 |
\cs_new_protected:Npn \__xtemplate_declare_template_code:nnnnn #1#2#3#4#5 |
| 417 |
{ |
| 418 |
\__xtemplate_execute_if_type_exist:nT {#1} |
| 419 |
{ |
| 420 |
\__xtemplate_execute_if_arg_agree:nnT {#1}{#3} |
| 421 |
{ |
| 422 |
\__xtemplate_if_keys_exist:nnT {#1} {#2} |
| 423 |
{ |
| 424 |
\__xtemplate_store_key_implementation:nnn {#1} {#2} {#4} |
| 425 |
\regex_match:nnTF { \c { AssignTemplateKeys } } {#5} |
| 426 |
{ \__xtemplate_declare_template_code:nnn { #1 / #2 } {#3} {#5} } |
| 427 |
{ |
| 428 |
\__xtemplate_declare_template_code:nnn |
| 429 |
{ #1 / #2 } {#3} { \AssignTemplateKeys #5 } |
| 430 |
} |
| 431 |
} |
| 432 |
} |
| 433 |
} |
| 434 |
} |
| 435 |
\cs_new_protected:Npn \__xtemplate_declare_template_code:nnn #1#2#3 |
| 436 |
{ |
| 437 |
\cs_generate_from_arg_count:cNnn |
| 438 |
{ \c__xtemplate_code_root_tl #1 } |
| 439 |
\cs_gset_protected:Npn {#2} {#3} |
| 440 |
} |
| 441 |
\cs_new_protected:Npn \__xtemplate_store_key_implementation:nnn #1#2#3 |
| 442 |
{ |
| 443 |
\__xtemplate_recover_defaults:n { #1 / #2 } |
| 444 |
\__xtemplate_recover_restrictions:n { #1 / #2 } |
| 445 |
\__xtemplate_recover_keytypes:n { #1 / #2 } |
| 446 |
\prop_clear:N \l__xtemplate_vars_prop |
| 447 |
\keyval_parse:nnn |
| 448 |
{ \__xtemplate_parse_vars_elt:n } { \__xtemplate_parse_vars_elt:nnn { #1 / #2 } } {#3} |
| 449 |
\__xtemplate_store_vars:n { #1 / #2 } |
| 450 |
\__xtemplate_store_restrictions:n { #1 / #2 } |
| 451 |
\prop_map_inline:Nn \l__xtemplate_keytypes_prop |
| 452 |
{ |
| 453 |
\msg_error:nneee { xtemplate } { key-not-implemented } |
| 454 |
{##1} {#2} {#1} |
| 455 |
} |
| 456 |
} |
| 457 |
\cs_new_protected:Npn \__xtemplate_parse_vars_elt:n #1 |
| 458 |
{ \msg_error:nne { xtemplate } { key-no-variable } {#1} } |
| 459 |
\cs_new_protected:Npn \__xtemplate_parse_vars_elt:nnn #1#2#3 |
| 460 |
{ |
| 461 |
\tl_set:Ne \l__xtemplate_key_name_tl |
| 462 |
{ \tl_trim_spaces:e { \tl_to_str:n {#2} } } |
| 463 |
\prop_get:NoNTF |
| 464 |
\l__xtemplate_keytypes_prop |
| 465 |
\l__xtemplate_key_name_tl |
| 466 |
\l__xtemplate_keytype_tl |
| 467 |
{ |
| 468 |
\__xtemplate_split_keytype_arg:o \l__xtemplate_keytype_tl |
| 469 |
\__xtemplate_parse_vars_elt_aux:nn {#1} {#3} |
| 470 |
\prop_remove:NV \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl |
| 471 |
} |
| 472 |
{ \msg_error:nne { xtemplate } { unknown-key } {#2} } |
| 473 |
} |
| 474 |
\cs_new_protected:Npn \__xtemplate_parse_vars_elt_aux:nn #1#2 |
| 475 |
{ |
| 476 |
\__xtemplate_parse_vars_elt_aux:nw {#1} #2 global global \s__xtemplate_stop |
| 477 |
} |
| 478 |
\cs_new_protected:Npn \__xtemplate_parse_vars_elt_aux:nw |
| 479 |
#1#2 global #3 global #4 \s__xtemplate_stop |
| 480 |
{ |
| 481 |
\tl_if_blank:nTF {#4} |
| 482 |
{ \__xtemplate_parse_vars_elt_aux:nnn {#1} { } {#2} } |
| 483 |
{ |
| 484 |
\tl_if_blank:nTF {#2} |
| 485 |
{ |
| 486 |
\exp_args:Nnne \__xtemplate_parse_vars_elt_aux:nnn |
| 487 |
{#1} { global } { \tl_trim_spaces:n {#3} } |
| 488 |
} |
| 489 |
{ \msg_error:nnn { xtemplate } { bad-variable } { #2 global #3 } } |
| 490 |
} |
| 491 |
} |
| 492 |
\cs_new_protected:Npn \__xtemplate_parse_vars_elt_aux:nnn #1#2#3 |
| 493 |
{ |
| 494 |
\str_case:VnF \l__xtemplate_keytype_tl |
| 495 |
{ |
| 496 |
{ choice } { \__xtemplate_implement_choices:nn {#1} {#3} } |
| 497 |
{ function } |
| 498 |
{ |
| 499 |
\cs_if_exist:NF #3 |
| 500 |
{ \cs_new:Npn #3 { } } |
| 501 |
\__xtemplate_parse_vars_elt_key:nn {#1} |
| 502 |
{ |
| 503 |
.code:n = |
| 504 |
{ |
| 505 |
\cs_generate_from_arg_count:NNnn |
| 506 |
\exp_not:N #3 |
| 507 |
\exp_not:c |
| 508 |
{ cs_ \str_if_eq:nnT {#1} { global } { g } set:Npn } |
| 509 |
{ \exp_not:o \l__xtemplate_keytype_arg_tl } |
| 510 |
{##1} |
| 511 |
} |
| 512 |
} |
| 513 |
\prop_put:Non \l__xtemplate_vars_prop |
| 514 |
\l__xtemplate_key_name_tl {#2#3} |
| 515 |
} |
| 516 |
{ instance } |
| 517 |
{ |
| 518 |
\__xtemplate_parse_vars_elt_key:nn {#1} |
| 519 |
{ |
| 520 |
.code:n = |
| 521 |
{ |
| 522 |
\exp_not:c |
| 523 |
{ cs_ \str_if_eq:nnT {#1} { global } { g } set:Npn } |
| 524 |
\exp_not:N #3 { \UseInstance {##1} } |
| 525 |
} |
| 526 |
} |
| 527 |
\prop_put:Non \l__xtemplate_vars_prop |
| 528 |
\l__xtemplate_key_name_tl {#2#3} |
| 529 |
} |
| 530 |
} |
| 531 |
{ |
| 532 |
\tl_if_single:nTF {#3} |
| 533 |
{ |
| 534 |
\cs_if_exist:NF #3 |
| 535 |
{ \use:c { \__xtemplate_map_var_type: _new:N } #3 } |
| 536 |
\__xtemplate_parse_vars_elt_key:nn {#1} |
| 537 |
{ |
| 538 |
. \__xtemplate_map_var_type: |
| 539 |
_ \str_if_eq:nnT {#1} { global } { g } set:N |
| 540 |
= \exp_not:N #3 |
| 541 |
} |
| 542 |
\prop_put:Non \l__xtemplate_vars_prop |
| 543 |
\l__xtemplate_key_name_tl {#2#3} |
| 544 |
} |
| 545 |
{ \msg_error:nne { xtemplate } { bad-variable } { #2#3 } } |
| 546 |
} |
| 547 |
} |
| 548 |
\cs_new_protected:Npn \__xtemplate_parse_vars_elt_key:nn #1#2 |
| 549 |
{ |
| 550 |
\keys_define:ne { template / #1 } |
| 551 |
{ \l__xtemplate_key_name_tl #2 } |
| 552 |
} |
| 553 |
\cs_new:Npn \__xtemplate_map_var_type: |
| 554 |
{ |
| 555 |
\str_case:on \l__xtemplate_keytype_tl |
| 556 |
{ |
| 557 |
{ boolean } { bool } |
| 558 |
{ commalist } { clist } |
| 559 |
{ integer } { int } |
| 560 |
{ length } { dim } |
| 561 |
{ muskip } { muskip } |
| 562 |
{ real } { fp } |
| 563 |
{ skip } { skip } |
| 564 |
{ tokenlist } { tl } |
| 565 |
} |
| 566 |
} |
| 567 |
\cs_new_protected:Npn \__xtemplate_implement_choices:nn #1#2 |
| 568 |
{ |
| 569 |
\clist_set:No \l__xtemplate_tmp_clist { \l__xtemplate_keytype_arg_tl } |
| 570 |
\prop_put:Non \l__xtemplate_vars_prop \l__xtemplate_key_name_tl { } |
| 571 |
\keys_define:ne { template / #1 } { \l__xtemplate_key_name_tl .choice: } |
| 572 |
\keyval_parse:nnn |
| 573 |
{ \__xtemplate_implement_choice_elt:n } |
| 574 |
{ \__xtemplate_implement_choice_elt:nnn {#1} } |
| 575 |
{#2} |
| 576 |
\prop_get:NoNT \l__xtemplate_values_prop \l__xtemplate_key_name_tl |
| 577 |
\l__xtemplate_tmp_tl |
| 578 |
{ \__xtemplate_implement_choices_default: } |
| 579 |
\clist_if_empty:NF \l__xtemplate_tmp_clist |
| 580 |
{ |
| 581 |
\clist_map_inline:Nn \l__xtemplate_tmp_clist |
| 582 |
{ |
| 583 |
\msg_error:nne { xtemplate } { choice-not-implemented } |
| 584 |
{##1} |
| 585 |
} |
| 586 |
} |
| 587 |
} |
| 588 |
\cs_new_protected:Npn \__xtemplate_implement_choices_default: |
| 589 |
{ |
| 590 |
\tl_set:Ne \l__xtemplate_tmp_tl |
| 591 |
{ \l__xtemplate_key_name_tl \c_space_tl \l__xtemplate_tmp_tl } |
| 592 |
\prop_if_in:NoF \l__xtemplate_vars_prop \l__xtemplate_tmp_tl |
| 593 |
{ |
| 594 |
\tl_set:Ne \l__xtemplate_tmp_tl |
| 595 |
{ \l__xtemplate_key_name_tl \c_space_tl \l__xtemplate_tmp_tl } |
| 596 |
\prop_if_in:NoF \l__xtemplate_vars_prop \l__xtemplate_tmp_tl |
| 597 |
{ |
| 598 |
\prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl |
| 599 |
\l__xtemplate_tmp_tl |
| 600 |
\__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl |
| 601 |
\prop_get:NoN \l__xtemplate_values_prop \l__xtemplate_key_name_tl |
| 602 |
\l__xtemplate_tmp_tl |
| 603 |
\msg_error:nneee { xtemplate } { unknown-default-choice } |
| 604 |
{ \l__xtemplate_key_name_tl } { \l__xtemplate_key_name_tl } |
| 605 |
{ \l__xtemplate_keytype_arg_tl } |
| 606 |
} |
| 607 |
} |
| 608 |
} |
| 609 |
\cs_new_protected:Npn \__xtemplate_implement_choice_elt:nnn #1#2#3 |
| 610 |
{ |
| 611 |
\clist_if_empty:NTF \l__xtemplate_tmp_clist |
| 612 |
{ |
| 613 |
\str_if_eq:nnTF {#2} { unknown } |
| 614 |
{ \__xtemplate_implement_choice_elt_aux:nnn {#1} {#2} {#3} } |
| 615 |
{ |
| 616 |
\prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl |
| 617 |
\l__xtemplate_tmp_tl |
| 618 |
\__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl |
| 619 |
\msg_error:nneee { xtemplate } { unknown-choice } |
| 620 |
{ \l__xtemplate_key_name_tl } {#2} |
| 621 |
{ \l__xtemplate_keytype_arg_tl } |
| 622 |
} |
| 623 |
} |
| 624 |
{ |
| 625 |
\clist_if_in:NnTF \l__xtemplate_tmp_clist {#2} |
| 626 |
{ |
| 627 |
\clist_remove_all:Nn \l__xtemplate_tmp_clist {#2} |
| 628 |
\__xtemplate_implement_choice_elt_aux:nnn {#1} {#2} {#3} |
| 629 |
} |
| 630 |
{ |
| 631 |
\prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl |
| 632 |
\l__xtemplate_tmp_tl |
| 633 |
\__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl |
| 634 |
\msg_error:nneee { xtemplate } { unknown-choice } |
| 635 |
{ \l__xtemplate_key_name_tl } {#2} |
| 636 |
{ \l__xtemplate_keytype_arg_tl } |
| 637 |
} |
| 638 |
} |
| 639 |
} |
| 640 |
\cs_new_protected:Npn \__xtemplate_implement_choice_elt_aux:nnn #1#2#3 |
| 641 |
{ |
| 642 |
\keys_define:ne { template / #1 } |
| 643 |
{ \l__xtemplate_key_name_tl / #2 .code:n = { \exp_not:n {#3} } } |
| 644 |
\tl_set:Ne \l__xtemplate_tmp_tl |
| 645 |
{ \l__xtemplate_key_name_tl \c_space_tl #2 } |
| 646 |
\prop_put:Non \l__xtemplate_vars_prop \l__xtemplate_tmp_tl {#3} |
| 647 |
} |
| 648 |
\cs_new_protected:Npn \__xtemplate_implement_choice_elt:n #1 |
| 649 |
{ |
| 650 |
\msg_error:nneee { xtemplate } { choice-requires-code } |
| 651 |
{ \l__xtemplate_key_name_tl } {#1} |
| 652 |
} |
| 653 |
\cs_new_protected:Npn \__xtemplate_declare_restricted:nnnn #1#2#3#4 |
| 654 |
{ |
| 655 |
\__xtemplate_if_keys_exist:nnT {#1} {#2} |
| 656 |
{ |
| 657 |
\__xtemplate_set_template_eq:nn { #1 / #3 } { #1 / #2 } |
| 658 |
\bool_set_true:N \l__xtemplate_restrict_bool |
| 659 |
\__xtemplate_edit_defaults_aux:nnn {#1} {#3} {#4} |
| 660 |
\bool_set_false:N \l__xtemplate_restrict_bool |
| 661 |
} |
| 662 |
} |
| 663 |
\cs_new_protected:Npn \__xtemplate_edit_defaults:nnn |
| 664 |
{ |
| 665 |
\bool_set_false:N \l__xtemplate_restrict_bool |
| 666 |
\__xtemplate_edit_defaults_aux:nnn |
| 667 |
} |
| 668 |
\cs_new_protected:Npn \__xtemplate_edit_defaults_aux:nnn #1#2#3 |
| 669 |
{ |
| 670 |
\__xtemplate_if_keys_exist:nnT {#1} {#2} |
| 671 |
{ |
| 672 |
\__xtemplate_recover_defaults:n { #1 / #2 } |
| 673 |
\__xtemplate_recover_restrictions:n { #1 / #2 } |
| 674 |
\__xtemplate_parse_values:nn { #1 / #2 } {#3} |
| 675 |
\__xtemplate_store_defaults:n { #1 / #2 } |
| 676 |
\__xtemplate_store_restrictions:n { #1 / #2 } |
| 677 |
} |
| 678 |
} |
| 679 |
\cs_new_protected:Npn \__xtemplate_parse_values:nn #1#2 |
| 680 |
{ |
| 681 |
\clist_clear:N \l__xtemplate_restrict_clist |
| 682 |
\__xtemplate_parse_values_aux:nn {#1} {#2} |
| 683 |
} |
| 684 |
\cs_new_protected:Npn \__xtemplate_parse_values_aux:nn #1#2 |
| 685 |
{ |
| 686 |
\__xtemplate_recover_keytypes:n {#1} |
| 687 |
\keyval_parse:NNn |
| 688 |
\__xtemplate_parse_values_elt:n \__xtemplate_parse_values_elt:nn {#2} |
| 689 |
} |
| 690 |
\cs_new_protected:Npn \__xtemplate_parse_values_elt:n #1 |
| 691 |
{ |
| 692 |
\bool_set_true:N \l__xtemplate_error_bool |
| 693 |
\msg_error:nne { xtemplate } { key-no-value } {#1} |
| 694 |
} |
| 695 |
\cs_new_protected:Npn \__xtemplate_parse_values_elt:nn #1#2 |
| 696 |
{ |
| 697 |
\tl_set:Ne \l__xtemplate_key_name_tl |
| 698 |
{ \tl_trim_spaces:e { \tl_to_str:n {#1} } } |
| 699 |
\prop_get:NoNTF \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl |
| 700 |
\l__xtemplate_tmp_tl |
| 701 |
{ |
| 702 |
\bool_if:NTF \l__xtemplate_restrict_bool |
| 703 |
{ |
| 704 |
\clist_if_in:NoF \l__xtemplate_restrict_clist |
| 705 |
\l__xtemplate_key_name_tl |
| 706 |
{ \__xtemplate_parse_values_elt_aux:n {#2} } |
| 707 |
} |
| 708 |
{ \__xtemplate_parse_values_elt_aux:n {#2} } |
| 709 |
} |
| 710 |
{ |
| 711 |
\msg_error:nne { xtemplate } { unknown-key } |
| 712 |
{ \l__xtemplate_key_name_tl } |
| 713 |
} |
| 714 |
} |
| 715 |
\cs_new_protected:Npn \__xtemplate_parse_values_elt_aux:n #1 |
| 716 |
{ |
| 717 |
\clist_put_right:No \l__xtemplate_restrict_clist \l__xtemplate_key_name_tl |
| 718 |
\__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl |
| 719 |
\use:c { __xtemplate_store_value_ \l__xtemplate_keytype_tl :n } {#1} |
| 720 |
} |
| 721 |
\cs_new_protected:Npn \__xtemplate_set_template_eq:nn #1#2 |
| 722 |
{ |
| 723 |
\__xtemplate_recover_defaults:n {#2} |
| 724 |
\__xtemplate_store_defaults:n {#1} |
| 725 |
\__xtemplate_recover_keytypes:n {#2} |
| 726 |
\__xtemplate_store_keytypes:n {#1} |
| 727 |
\__xtemplate_recover_vars:n {#2} |
| 728 |
\__xtemplate_store_vars:n {#1} |
| 729 |
\cs_gset_eq:cc { \c__xtemplate_code_root_tl #1 } |
| 730 |
{ \c__xtemplate_code_root_tl #2 } |
| 731 |
} |
| 732 |
\cs_new_protected:Npn \__xtemplate_declare_instance:nnnnn #1#2#3#4#5 |
| 733 |
{ |
| 734 |
\__xtemplate_execute_if_code_exist:nnT {#1} {#2} |
| 735 |
{ |
| 736 |
\__xtemplate_recover_defaults:n { #1 / #2 } |
| 737 |
\__xtemplate_recover_restrictions:n { #1 / #2 } |
| 738 |
\__xtemplate_recover_vars:n { #1 / #2 } |
| 739 |
\__xtemplate_declare_instance_aux:nnnnn {#1} {#2} {#3} {#4} {#5} |
| 740 |
} |
| 741 |
} |
| 742 |
\cs_new_protected:Npn \__xtemplate_declare_instance_aux:nnnnn #1#2#3#4#5 |
| 743 |
{ |
| 744 |
\bool_set_false:N \l__xtemplate_error_bool |
| 745 |
\__xtemplate_parse_values_aux:nn { #1 / #2 } {#5} |
| 746 |
\bool_if:NF \l__xtemplate_error_bool |
| 747 |
{ |
| 748 |
\prop_put:Nnn \l__xtemplate_values_prop { from~template } {#2} |
| 749 |
\__xtemplate_store_values:n { #1 / #3 / #4 } |
| 750 |
\__xtemplate_convert_to_assignments: |
| 751 |
\cs_set_protected:cpe { \c__xtemplate_instances_root_tl #1 / #3 / #4 } |
| 752 |
{ |
| 753 |
\exp_not:N \__xtemplate_assignments_push:n |
| 754 |
{ \exp_not:o \l__xtemplate_assignments_tl } |
| 755 |
\exp_not:c { \c__xtemplate_code_root_tl #1 / #2 } |
| 756 |
} |
| 757 |
\__xtemplate_if_instance_exist:nnnF {#1} { } {#4} |
| 758 |
{ |
| 759 |
\cs_set_eq:cc |
| 760 |
{ \c__xtemplate_instances_root_tl #1 / / #4 } |
| 761 |
{ \c__xtemplate_instances_root_tl #1 / #3 / #4 } |
| 762 |
} |
| 763 |
} |
| 764 |
} |
| 765 |
\cs_new_protected:Npn \__xtemplate_copy_instance:nnnn #1#2#3#4 |
| 766 |
{ |
| 767 |
\__xtemplate_if_instance_exist:nnnTF {#1} {#2} {#3} |
| 768 |
{ |
| 769 |
\__xtemplate_recover_values:n { #1 / #2 / #3 } |
| 770 |
\__xtemplate_store_values:n { #1 / #2 / #4 } |
| 771 |
\cs_set_eq:cc { \c__xtemplate_instances_root_tl #1 / #2 / #4 } |
| 772 |
{ \c__xtemplate_instances_root_tl #1 / #2 / #3 } |
| 773 |
} |
| 774 |
{ |
| 775 |
\msg_error:nnee { xtemplate } { unknown-instance } |
| 776 |
{#1} {#3} |
| 777 |
} |
| 778 |
} |
| 779 |
\cs_new_protected:Npn \__xtemplate_edit_instance:nnnn #1#2#3#4 |
| 780 |
{ |
| 781 |
\__xtemplate_if_instance_exist:nnnTF {#1} {#2} {#3} |
| 782 |
{ |
| 783 |
\__xtemplate_recover_values:n { #1 / #2 / #3 } |
| 784 |
\prop_get:NnN \l__xtemplate_values_prop { from~template } |
| 785 |
\l__xtemplate_tmp_tl |
| 786 |
\__xtemplate_edit_instance_aux:nonnn {#1} \l__xtemplate_tmp_tl |
| 787 |
{#2} {#3} {#4} |
| 788 |
} |
| 789 |
{ |
| 790 |
\msg_error:nnee { xtemplate } { unknown-instance } |
| 791 |
{#1} {#3} |
| 792 |
} |
| 793 |
} |
| 794 |
\cs_new_protected:Npn \__xtemplate_edit_instance_aux:nnnnn #1#2 |
| 795 |
{ |
| 796 |
\__xtemplate_recover_vars:n { #1 / #2 } |
| 797 |
\__xtemplate_declare_instance_aux:nnnnn {#1} {#2} |
| 798 |
} |
| 799 |
\cs_generate_variant:Nn \__xtemplate_edit_instance_aux:nnnnn { no } |
| 800 |
\cs_new_protected:Npn \__xtemplate_convert_to_assignments: |
| 801 |
{ |
| 802 |
\tl_clear:N \l__xtemplate_assignments_tl |
| 803 |
\seq_map_function:NN \l__xtemplate_key_order_seq |
| 804 |
\__xtemplate_convert_to_assignments_aux:n |
| 805 |
} |
| 806 |
\cs_new_protected:Npn \__xtemplate_convert_to_assignments_aux:n #1 |
| 807 |
{ |
| 808 |
\prop_get:NnN \l__xtemplate_keytypes_prop {#1} \l__xtemplate_tmp_tl |
| 809 |
\__xtemplate_convert_to_assignments_aux:no {#1} \l__xtemplate_tmp_tl |
| 810 |
} |
| 811 |
\cs_new_protected:Npn \__xtemplate_convert_to_assignments_aux:nn #1#2 |
| 812 |
{ |
| 813 |
\prop_get:NnNT \l__xtemplate_values_prop {#1} \l__xtemplate_value_tl |
| 814 |
{ |
| 815 |
\prop_get:NnNTF \l__xtemplate_vars_prop {#1} \l__xtemplate_var_tl |
| 816 |
{ |
| 817 |
\__xtemplate_split_keytype_arg:n {#2} |
| 818 |
\str_if_eq:onF \l__xtemplate_keytype_tl { choice } |
| 819 |
{ |
| 820 |
\str_if_eq:onF \l__xtemplate_keytype_tl { code } |
| 821 |
{ \__xtemplate_find_global: } |
| 822 |
} |
| 823 |
\tl_set:Nn \l__xtemplate_key_name_tl {#1} |
| 824 |
\use:c { __xtemplate_assign_ \l__xtemplate_keytype_tl : } |
| 825 |
} |
| 826 |
{ \msg_error:nne { xtemplate } { unknown-attribute } {#1} } |
| 827 |
} |
| 828 |
} |
| 829 |
\cs_generate_variant:Nn \__xtemplate_convert_to_assignments_aux:nn { no } |
| 830 |
\cs_new_protected:Npn \__xtemplate_find_global: |
| 831 |
{ |
| 832 |
\bool_set_false:N \l__xtemplate_global_bool |
| 833 |
\tl_if_in:onT \l__xtemplate_var_tl { global } |
| 834 |
{ |
| 835 |
\exp_after:wN \__xtemplate_find_global_aux:w \l__xtemplate_var_tl \s__xtemplate_stop |
| 836 |
} |
| 837 |
} |
| 838 |
\cs_new_protected:Npn \__xtemplate_find_global_aux:w #1 global #2 \s__xtemplate_stop |
| 839 |
{ |
| 840 |
\tl_set:Nn \l__xtemplate_var_tl {#2} |
| 841 |
\bool_set_true:N \l__xtemplate_global_bool |
| 842 |
} |
| 843 |
\cs_new_protected:Npn \__xtemplate_use_template:nnn #1#2#3 |
| 844 |
{ |
| 845 |
\__xtemplate_execute_if_code_exist:nnT {#1} {#2} |
| 846 |
{ |
| 847 |
\__xtemplate_recover_defaults:n { #1 / #2 } |
| 848 |
\__xtemplate_recover_vars:n { #1 / #2 } |
| 849 |
\__xtemplate_parse_values:nn { #1 / #2 } {#3} |
| 850 |
\__xtemplate_convert_to_assignments: |
| 851 |
\use:c { \c__xtemplate_code_root_tl #1 / #2 } |
| 852 |
} |
| 853 |
} |
| 854 |
\cs_new_protected:Npn \__xtemplate_assign_boolean: |
| 855 |
{ |
| 856 |
\bool_if:NTF \l__xtemplate_global_bool |
| 857 |
{ \__xtemplate_assign_boolean_aux:n { bool_gset } } |
| 858 |
{ \__xtemplate_assign_boolean_aux:n { bool_set } } |
| 859 |
} |
| 860 |
\cs_new_protected:Npn \__xtemplate_assign_boolean_aux:n #1 |
| 861 |
{ |
| 862 |
\__xtemplate_if_key_value:oTF \l__xtemplate_value_tl |
| 863 |
{ |
| 864 |
\__xtemplate_key_to_value: |
| 865 |
\tl_put_right:Ne \l__xtemplate_assignments_tl |
| 866 |
{ |
| 867 |
\exp_not:c { #1 _eq:NN } |
| 868 |
\exp_not:o \l__xtemplate_var_tl |
| 869 |
\exp_not:o \l__xtemplate_value_tl |
| 870 |
} |
| 871 |
} |
| 872 |
{ |
| 873 |
\tl_put_right:Ne \l__xtemplate_assignments_tl |
| 874 |
{ |
| 875 |
\exp_not:c { #1 _ \l__xtemplate_value_tl :N } |
| 876 |
\exp_not:o \l__xtemplate_var_tl |
| 877 |
} |
| 878 |
} |
| 879 |
} |
| 880 |
\cs_new_protected:Npn \__xtemplate_assign_choice: |
| 881 |
{ |
| 882 |
\__xtemplate_assign_choice_aux:eF |
| 883 |
{ \l__xtemplate_key_name_tl \c_space_tl \l__xtemplate_value_tl } |
| 884 |
{ |
| 885 |
\__xtemplate_assign_choice_aux:eF |
| 886 |
{ \l__xtemplate_key_name_tl \c_space_tl unknown } |
| 887 |
{ |
| 888 |
\prop_get:NoN \l__xtemplate_keytypes_prop \l__xtemplate_key_name_tl |
| 889 |
\l__xtemplate_tmp_tl |
| 890 |
\__xtemplate_split_keytype_arg:o \l__xtemplate_tmp_tl |
| 891 |
\msg_error:nneee { xtemplate } { unknown-choice } |
| 892 |
{ \l__xtemplate_key_name_tl } { \l__xtemplate_value_tl } |
| 893 |
{ \l__xtemplate_keytype_arg_tl } |
| 894 |
} |
| 895 |
} |
| 896 |
} |
| 897 |
\cs_new_protected:Npn \__xtemplate_assign_choice_aux:nF #1 |
| 898 |
{ |
| 899 |
\prop_get:NnNTF |
| 900 |
\l__xtemplate_vars_prop |
| 901 |
{#1} |
| 902 |
\l__xtemplate_tmp_tl |
| 903 |
{ \tl_put_right:No \l__xtemplate_assignments_tl \l__xtemplate_tmp_tl } |
| 904 |
} |
| 905 |
\cs_generate_variant:Nn \__xtemplate_assign_choice_aux:nF { e } |
| 906 |
\cs_new_protected:Npn \__xtemplate_assign_function: |
| 907 |
{ |
| 908 |
\bool_if:NTF \l__xtemplate_global_bool |
| 909 |
{ \__xtemplate_assign_function_aux:N \cs_gset:Npn } |
| 910 |
{ \__xtemplate_assign_function_aux:N \cs_set:Npn } |
| 911 |
} |
| 912 |
\cs_new_protected:Npn \__xtemplate_assign_function_aux:N #1 |
| 913 |
{ |
| 914 |
\tl_put_right:Ne \l__xtemplate_assignments_tl |
| 915 |
{ |
| 916 |
\cs_generate_from_arg_count:NNnn |
| 917 |
\exp_not:o \l__xtemplate_var_tl |
| 918 |
\exp_not:N #1 |
| 919 |
{ \exp_not:o \l__xtemplate_keytype_arg_tl } |
| 920 |
{ \exp_not:o \l__xtemplate_value_tl } |
| 921 |
} |
| 922 |
} |
| 923 |
\cs_new_protected:Npn \__xtemplate_assign_instance: |
| 924 |
{ |
| 925 |
\bool_if:NTF \l__xtemplate_global_bool |
| 926 |
{ \__xtemplate_assign_instance_aux:N \cs_gset_protected:Npn } |
| 927 |
{ \__xtemplate_assign_instance_aux:N \cs_set_protected:Npn } |
| 928 |
} |
| 929 |
\cs_new_protected:Npn \__xtemplate_assign_instance_aux:N #1 |
| 930 |
{ |
| 931 |
\tl_put_right:Ne \l__xtemplate_assignments_tl |
| 932 |
{ |
| 933 |
\exp_not:N #1 \exp_not:o \l__xtemplate_var_tl |
| 934 |
{ |
| 935 |
\__xtemplate_use_instance:nn |
| 936 |
{ \exp_not:o \l__xtemplate_keytype_arg_tl } |
| 937 |
{ \exp_not:o \l__xtemplate_value_tl } |
| 938 |
} |
| 939 |
} |
| 940 |
} |
| 941 |
\cs_new_protected:Npn \__xtemplate_assign_integer: |
| 942 |
{ |
| 943 |
\bool_if:NTF \l__xtemplate_global_bool |
| 944 |
{ \__xtemplate_assign_variable:N \int_gset:Nn } |
| 945 |
{ \__xtemplate_assign_variable:N \int_set:Nn } |
| 946 |
} |
| 947 |
\cs_new_protected:Npn \__xtemplate_assign_length: |
| 948 |
{ |
| 949 |
\bool_if:NTF \l__xtemplate_global_bool |
| 950 |
{ \__xtemplate_assign_variable:N \dim_gset:Nn } |
| 951 |
{ \__xtemplate_assign_variable:N \dim_set:Nn } |
| 952 |
} |
| 953 |
\cs_new_protected:Npn \__xtemplate_assign_muskip: |
| 954 |
{ |
| 955 |
\bool_if:NTF \l__xtemplate_global_bool |
| 956 |
{ \__xtemplate_assign_variable:N \muskip_gset:Nn } |
| 957 |
{ \__xtemplate_assign_variable:N \muskip_set:Nn } |
| 958 |
} |
| 959 |
\cs_new_protected:Npn \__xtemplate_assign_real: |
| 960 |
{ |
| 961 |
\bool_if:NTF \l__xtemplate_global_bool |
| 962 |
{ \__xtemplate_assign_variable:N \fp_gset:Nn } |
| 963 |
{ \__xtemplate_assign_variable:N \fp_set:Nn } |
| 964 |
} |
| 965 |
\cs_new_protected:Npn \__xtemplate_assign_skip: |
| 966 |
{ |
| 967 |
\bool_if:NTF \l__xtemplate_global_bool |
| 968 |
{ \__xtemplate_assign_variable:N \skip_gset:Nn } |
| 969 |
{ \__xtemplate_assign_variable:N \skip_set:Nn } |
| 970 |
} |
| 971 |
\cs_new_protected:Npn \__xtemplate_assign_tokenlist: |
| 972 |
{ |
| 973 |
\bool_if:NTF \l__xtemplate_global_bool |
| 974 |
{ \__xtemplate_assign_tokenlist_aux:NN \tl_gset:NV \tl_gset:Nn } |
| 975 |
{ \__xtemplate_assign_tokenlist_aux:NN \tl_set:NV \tl_set:Nn } |
| 976 |
} |
| 977 |
\cs_new_protected:Npn \__xtemplate_assign_tokenlist_aux:NN #1#2 |
| 978 |
{ |
| 979 |
\__xtemplate_if_key_value:oTF \l__xtemplate_value_tl |
| 980 |
{ |
| 981 |
\__xtemplate_key_to_value: |
| 982 |
\tl_put_right:Ne \l__xtemplate_assignments_tl |
| 983 |
{ |
| 984 |
#1 \exp_not:o \l__xtemplate_var_tl |
| 985 |
\exp_not:o \l__xtemplate_value_tl |
| 986 |
} |
| 987 |
} |
| 988 |
{ |
| 989 |
\tl_put_right:Ne \l__xtemplate_assignments_tl |
| 990 |
{ |
| 991 |
#2 \exp_not:o \l__xtemplate_var_tl |
| 992 |
{ \exp_not:o \l__xtemplate_value_tl } |
| 993 |
} |
| 994 |
} |
| 995 |
} |
| 996 |
\cs_new_protected:Npn \__xtemplate_assign_commalist: |
| 997 |
{ |
| 998 |
\bool_if:NTF \l__xtemplate_global_bool |
| 999 |
{ \__xtemplate_assign_tokenlist_aux:NN \clist_gset:NV \clist_gset:Nn } |
| 1000 |
{ \__xtemplate_assign_tokenlist_aux:NN \clist_set:NV \clist_set:Nn } |
| 1001 |
} |
| 1002 |
\cs_new_protected:Npn \__xtemplate_assign_variable:N #1 |
| 1003 |
{ |
| 1004 |
\__xtemplate_if_key_value:oT \l__xtemplate_value_tl |
| 1005 |
{ \__xtemplate_key_to_value: } |
| 1006 |
\tl_put_right:Ne \l__xtemplate_assignments_tl |
| 1007 |
{ |
| 1008 |
#1 \exp_not:o \l__xtemplate_var_tl |
| 1009 |
{ \exp_not:o \l__xtemplate_value_tl } |
| 1010 |
} |
| 1011 |
} |
| 1012 |
\cs_new_protected:Npn \__xtemplate_key_to_value: |
| 1013 |
{ \exp_after:wN \__xtemplate_key_to_value_auxi:w \l__xtemplate_value_tl } |
| 1014 |
\cs_new_protected:Npn \__xtemplate_key_to_value_auxi:w \KeyValue #1 |
| 1015 |
{ |
| 1016 |
\tl_set:Ne \l__xtemplate_tmp_tl { \tl_trim_spaces:e { \tl_to_str:n {#1} } } |
| 1017 |
\prop_get:NoNTF |
| 1018 |
\l__xtemplate_vars_prop |
| 1019 |
\l__xtemplate_tmp_tl |
| 1020 |
\l__xtemplate_value_tl |
| 1021 |
{ |
| 1022 |
\exp_after:wN \__xtemplate_key_to_value_auxii:w \l__xtemplate_value_tl |
| 1023 |
\s__xtemplate_mark global \q__xtemplate_nil \s__xtemplate_stop |
| 1024 |
} |
| 1025 |
{ |
| 1026 |
\msg_error:nne { xtemplate } { unknown-attribute } |
| 1027 |
{ \l__xtemplate_tmp_tl } |
| 1028 |
} |
| 1029 |
} |
| 1030 |
\cs_new_protected:Npn \__xtemplate_key_to_value_auxii:w #1 global #2#3 \s__xtemplate_stop |
| 1031 |
{ |
| 1032 |
\__xtemplate_quark_if_nil:NF #2 |
| 1033 |
{ \tl_set:Nn \l__xtemplate_value_tl {#2} } |
| 1034 |
} |
| 1035 |
\cs_new_protected:Npn \__xtemplate_use_instance:nn #1#2 |
| 1036 |
{ |
| 1037 |
\__xtemplate_if_use_template:nTF {#2} |
| 1038 |
{ \__xtemplate_use_instance_aux:nNnnn {#1} #2 } |
| 1039 |
{ \__xtemplate_use_instance_aux:nn {#1} {#2} } |
| 1040 |
} |
| 1041 |
\cs_new_protected:Npn \__xtemplate_use_instance_aux:nNnnn #1#2#3#4#5 |
| 1042 |
{ |
| 1043 |
\str_if_eq:nnTF {#1} {#3} |
| 1044 |
{ \__xtemplate_use_template:nnn {#3} {#4} {#5} } |
| 1045 |
{ \msg_error:nnee { xtemplate } { type-mismatch } {#1} {#3} } |
| 1046 |
} |
| 1047 |
\cs_new_protected:Npn \__xtemplate_use_instance_aux:nn #1#2 |
| 1048 |
{ |
| 1049 |
\__xtemplate_get_collection:n {#1} |
| 1050 |
\__xtemplate_if_instance_exist:nnnTF |
| 1051 |
{#1} { \l__xtemplate_collection_tl } {#2} |
| 1052 |
{ |
| 1053 |
\use:c |
| 1054 |
{ |
| 1055 |
\c__xtemplate_instances_root_tl #1 / |
| 1056 |
\l__xtemplate_collection_tl / #2 |
| 1057 |
} |
| 1058 |
} |
| 1059 |
{ |
| 1060 |
\__xtemplate_if_instance_exist:nnnTF {#1} { } {#2} |
| 1061 |
{ \use:c { \c__xtemplate_instances_root_tl #1 / / #2 } } |
| 1062 |
{ |
| 1063 |
\msg_error:nnee { xtemplate } { unknown-instance } |
| 1064 |
{#1} {#2} |
| 1065 |
} |
| 1066 |
} |
| 1067 |
} |
| 1068 |
\cs_new_protected:Npn \__xtemplate_use_collection:nn #1#2 |
| 1069 |
{ \prop_put:Nnn \l__xtemplate_collections_prop {#1} {#2} } |
| 1070 |
\cs_new_protected:Npn \__xtemplate_get_collection:n #1 |
| 1071 |
{ |
| 1072 |
\prop_get:NnNF \l__xtemplate_collections_prop {#1} |
| 1073 |
\l__xtemplate_collection_tl |
| 1074 |
{ \tl_clear:N \l__xtemplate_collection_tl } |
| 1075 |
} |
| 1076 |
\cs_new:Npn \__xtemplate_assignments_pop: { \l__xtemplate_assignments_tl } |
| 1077 |
\cs_new_protected:Npn \__xtemplate_assignments_push:n #1 |
| 1078 |
{ \tl_set:Nn \l__xtemplate_assignments_tl {#1} } |
| 1079 |
\cs_new_protected:Npn \__xtemplate_show_code:nn #1#2 |
| 1080 |
{ \cs_show:c { \c__xtemplate_code_root_tl #1 / #2 } } |
| 1081 |
\cs_new_protected:Npn \__xtemplate_show_defaults:nn #1#2 |
| 1082 |
{ |
| 1083 |
\__xtemplate_if_keys_exist:nnT {#1} {#2} |
| 1084 |
{ |
| 1085 |
\__xtemplate_recover_defaults:n { #1 / #2 } |
| 1086 |
\__xtemplate_show:Nnnn \l__xtemplate_values_prop |
| 1087 |
{#1} {#2} { default~values } |
| 1088 |
} |
| 1089 |
} |
| 1090 |
\cs_new_protected:Npn \__xtemplate_show_keytypes:nn #1#2 |
| 1091 |
{ |
| 1092 |
\__xtemplate_if_keys_exist:nnT {#1} {#2} |
| 1093 |
{ |
| 1094 |
\__xtemplate_recover_keytypes:n { #1 / #2 } |
| 1095 |
\__xtemplate_show:Nnnn \l__xtemplate_keytypes_prop |
| 1096 |
{#1} {#2} { interface } |
| 1097 |
} |
| 1098 |
} |
| 1099 |
\cs_new_protected:Npn \__xtemplate_show_vars:nn #1#2 |
| 1100 |
{ |
| 1101 |
\__xtemplate_execute_if_code_exist:nnT {#1} {#2} |
| 1102 |
{ |
| 1103 |
\__xtemplate_recover_vars:n { #1 / #2 } |
| 1104 |
\__xtemplate_show:Nnnn \l__xtemplate_vars_prop |
| 1105 |
{#1} {#2} { variable~mapping } |
| 1106 |
} |
| 1107 |
} |
| 1108 |
\cs_new_protected:Npn \__xtemplate_show:Nnnn #1#2#3#4 |
| 1109 |
{ |
| 1110 |
\msg_show:nneeee { xtemplate } { show-attribute } |
| 1111 |
{ \tl_to_str:n {#2} } |
| 1112 |
{ \tl_to_str:n {#3} } |
| 1113 |
{ \tl_to_str:n {#4} } |
| 1114 |
{ \prop_map_function:NN #1 \msg_show_item_unbraced:nn } |
| 1115 |
} |
| 1116 |
\cs_new_protected:Npn \__xtemplate_show_values:nnn #1#2#3 |
| 1117 |
{ |
| 1118 |
\__xtemplate_if_instance_exist:nnnT {#1} {#2} {#3} |
| 1119 |
{ |
| 1120 |
\__xtemplate_recover_values:n { #1 / #2 / #3 } |
| 1121 |
\msg_show:nneeee { xtemplate } { show-values } |
| 1122 |
{ \tl_to_str:n {#1} } |
| 1123 |
{ \tl_to_str:n {#2} } |
| 1124 |
{ \tl_to_str:n {#3} } |
| 1125 |
{ |
| 1126 |
\prop_map_function:NN \l__xtemplate_values_prop |
| 1127 |
\msg_show_item_unbraced:nn |
| 1128 |
} |
| 1129 |
} |
| 1130 |
} |
| 1131 |
\msg_new:nnnn { xtemplate } { argument-number-mismatch } |
| 1132 |
{ Object~type~'#1'~takes~#2~argument(s). } |
| 1133 |
{ |
| 1134 |
Objects~of~type~'#1'~require~#2~argument(s).\\ |
| 1135 |
You~have~tried~to~make~a~template~for~'#1'~ |
| 1136 |
with~#3~argument(s),~which~is~not~possible:~ |
| 1137 |
the~number~of~arguments~must~agree. |
| 1138 |
} |
| 1139 |
\msg_new:nnnn { xtemplate } { bad-number-of-arguments } |
| 1140 |
{ Bad~number~of~arguments~for~object~type~'#1'. } |
| 1141 |
{ |
| 1142 |
An~object~may~accept~between~0~and~9~arguments.\\ |
| 1143 |
You~asked~to~use~#2~arguments:~this~is~not~supported. |
| 1144 |
} |
| 1145 |
\msg_new:nnnn { xtemplate } { bad-variable } |
| 1146 |
{ Incorrect~variable~description~'#1'. } |
| 1147 |
{ |
| 1148 |
The~argument~'#1'~is~not~of~the~form \\ |
| 1149 |
~~'<variable>'\\ |
| 1150 |
~or~\\ |
| 1151 |
~~'global~<variable>'.\\ |
| 1152 |
It~must~be~given~in~one~of~these~formats~to~be~used~in~a~template. |
| 1153 |
} |
| 1154 |
\msg_new:nnnn { xtemplate } { choice-not-implemented } |
| 1155 |
{ The~choice~'#1'~has~no~implementation. } |
| 1156 |
{ |
| 1157 |
Each~choice~listed~in~the~interface~for~a~template~must~ |
| 1158 |
have~an~implementation. |
| 1159 |
} |
| 1160 |
\msg_new:nnnn { xtemplate } { choice-no-code } |
| 1161 |
{ The~choice~'#1'~requires~implementation~details. } |
| 1162 |
{ |
| 1163 |
When~creating~template~code~using~\DeclareTemplateCode,~ |
| 1164 |
each~choice~name~must~have~an~associated~implementation.\\ |
| 1165 |
This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one. |
| 1166 |
} |
| 1167 |
\msg_new:nnnn { xtemplate } { choice-requires-code } |
| 1168 |
{ The~choice~'#2'~for~key~'#1'~requires~an~implementation. } |
| 1169 |
{ |
| 1170 |
You~should~have~put:\\ |
| 1171 |
\ \ #1~:~choice~{~#2 = <code> ~} \\ |
| 1172 |
but~LaTeX~did~not~find~any~<code>. |
| 1173 |
} |
| 1174 |
\msg_new:nnnn { xtemplate } { duplicate-key-interface } |
| 1175 |
{ Key~'#1'~appears~twice~in~interface~definition~\msg_line_context:. } |
| 1176 |
{ |
| 1177 |
Each~key~can~only~have~one~interface~declared~in~a~template.\\ |
| 1178 |
LaTeX~found~two~interfaces~for~'#1'. |
| 1179 |
} |
| 1180 |
\msg_new:nnnn { xtemplate } { keytype-requires-argument } |
| 1181 |
{ The~key~type~'#1'~requires~an~argument~\msg_line_context:. } |
| 1182 |
{ |
| 1183 |
You~should~have~put:\\ |
| 1184 |
\ \ <key-name>~:~#1~{~<argument>~} \\ |
| 1185 |
but~LaTeX~did~not~find~an~<argument>. |
| 1186 |
} |
| 1187 |
\msg_new:nnnn { xtemplate } { invalid-keytype } |
| 1188 |
{ The~key~'#1'~is~missing~a~key-type~\msg_line_context:. } |
| 1189 |
{ |
| 1190 |
Each~key~in~a~template~requires~a~key-type,~given~in~the~form:\\ |
| 1191 |
\ \ <key>~:~<key-type>\\ |
| 1192 |
LaTeX~could~not~find~a~<key-type>~in~your~input. |
| 1193 |
} |
| 1194 |
\msg_new:nnnn { xtemplate } { key-no-value } |
| 1195 |
{ The~key~'#1'~has~no~value~\msg_line_context:. } |
| 1196 |
{ |
| 1197 |
When~creating~an~instance~of~a~template~ |
| 1198 |
every~key~listed~must~include~a~value:\\ |
| 1199 |
\ \ <key>~=~<value> |
| 1200 |
} |
| 1201 |
\msg_new:nnnn { xtemplate } { key-no-variable } |
| 1202 |
{ The~key~'#1'~requires~implementation~details~\msg_line_context:. } |
| 1203 |
{ |
| 1204 |
When~creating~template~code~using~\DeclareTemplateCode,~ |
| 1205 |
each~key~name~must~have~an~associated~implementation.\\ |
| 1206 |
This~should~be~given~after~a~'='~sign:~LaTeX~did~not~find~one. |
| 1207 |
} |
| 1208 |
\msg_new:nnnn { xtemplate } { key-not-implemented } |
| 1209 |
{ Key~'#1'~has~no~implementation~\msg_line_context:. } |
| 1210 |
{ |
| 1211 |
The~definition~of~key~implementations~for~template~'#2'~ |
| 1212 |
of~object~type~'#3'~does~not~include~any~details~for~key~'#1'.\\ |
| 1213 |
The~key~was~declared~in~the~interface~definition,~ |
| 1214 |
and~so~an~implementation~is~required. |
| 1215 |
} |
| 1216 |
\msg_new:nnnn { xtemplate } { missing-keytype } |
| 1217 |
{ The~key~'#1'~is~missing~a~key-type~\msg_line_context:. } |
| 1218 |
{ |
| 1219 |
Key~interface~definitions~should~be~of~the~form\\ |
| 1220 |
\ \ #1~:~<key-type>\\ |
| 1221 |
but~LaTeX~could~not~find~a~<key-type>. |
| 1222 |
} |
| 1223 |
\msg_new:nnnn { xtemplate } { no-template-code } |
| 1224 |
{ |
| 1225 |
The~template~'#2'~of~type~'#1'~is~unknown~ |
| 1226 |
or~has~no~implementation. |
| 1227 |
} |
| 1228 |
{ |
| 1229 |
There~is~no~code~available~for~the~template~name~given.\\ |
| 1230 |
This~should~be~given~using~\DeclareTemplateCode. |
| 1231 |
} |
| 1232 |
\msg_new:nnnn { xtemplate } { object-type-mismatch } |
| 1233 |
{ Object~types~'#1'~and~'#2'~do~not~agree. } |
| 1234 |
{ |
| 1235 |
You~are~trying~to~use~a~template~directly~with~\UseInstance |
| 1236 |
(or~a~similar~function),~but~the~object~types~do~not~match. |
| 1237 |
} |
| 1238 |
\msg_new:nnnn { xtemplate } { unknown-attribute } |
| 1239 |
{ The~template~attribute~'#1'~is~unknown. } |
| 1240 |
{ |
| 1241 |
There~is~a~definition~in~the~current~template~reading\\ |
| 1242 |
\ \ \token_to_str:N \KeyValue {~#1~} \\ |
| 1243 |
but~there~is~no~key~called~'#1'. |
| 1244 |
} |
| 1245 |
\msg_new:nnnn { xtemplate } { unknown-choice } |
| 1246 |
{ The~choice~'#2'~was~not~declared~for~key~'#1'. } |
| 1247 |
{ |
| 1248 |
The~key~'#1'~takes~a~fixed~list~of~choices~ |
| 1249 |
and~this~list~does~not~include~'#2'. |
| 1250 |
} |
| 1251 |
\msg_new:nnnn { xtemplate } { unknown-default-choice } |
| 1252 |
{ The~default~choice~'#2'~was~not~declared~for~key~'#1'. } |
| 1253 |
{ |
| 1254 |
The~key~'#1'~takes~a~fixed~list~of~choices~ |
| 1255 |
and~this~list~does~not~include~'#2'. |
| 1256 |
} |
| 1257 |
\msg_new:nnnn { xtemplate } { unknown-instance } |
| 1258 |
{ The~instance~'#2'~of~type~'#1'~is~unknown. } |
| 1259 |
{ |
| 1260 |
You~have~asked~to~use~an~instance~'#2',~ |
| 1261 |
but~this~has~not~been~created. |
| 1262 |
} |
| 1263 |
\msg_new:nnnn { xtemplate } { unknown-key } |
| 1264 |
{ Unknown~template~key~'#1'. } |
| 1265 |
{ |
| 1266 |
The~key~'#1'~was~not~declared~in~the~interface~ |
| 1267 |
for~the~current~template. |
| 1268 |
} |
| 1269 |
\msg_new:nnnn { xtemplate } { unknown-keytype } |
| 1270 |
{ The~key-type~'#1'~is~unknown. } |
| 1271 |
{ |
| 1272 |
Valid~key-types~are:\\ |
| 1273 |
-~boolean;\\ |
| 1274 |
-~choice;\\ |
| 1275 |
-~commalist;\\ |
| 1276 |
-~function;\\ |
| 1277 |
-~instance;\\ |
| 1278 |
-~integer;\\ |
| 1279 |
-~length;\\ |
| 1280 |
-~muskip;\\ |
| 1281 |
-~real;\\ |
| 1282 |
-~skip;\\ |
| 1283 |
-~tokenlist. |
| 1284 |
} |
| 1285 |
\msg_new:nnnn { xtemplate } { unknown-object-type } |
| 1286 |
{ The~object~type~'#1'~is~unknown. } |
| 1287 |
{ |
| 1288 |
An~object~type~needs~to~be~declared~with~\DeclareObjectType |
| 1289 |
prior~to~using~it. |
| 1290 |
} |
| 1291 |
\msg_new:nnnn { xtemplate } { unknown-template } |
| 1292 |
{ The~template~'#2'~of~type~'#1'~is~unknown. } |
| 1293 |
{ |
| 1294 |
No~interface~has~been~declared~for~a~template~ |
| 1295 |
'#2'~of~object~type~'#1'. |
| 1296 |
} |
| 1297 |
\msg_new:nnn { xtemplate } { declare-object-type } |
| 1298 |
{ Declaring~object~type~'#1'~taking~#2~argument(s)~\msg_line_context:. } |
| 1299 |
\msg_new:nnn { xtemplate } { declare-template-code } |
| 1300 |
{ Declaring~code~for~template~'#2'~of~object~type'#1'~\msg_line_context:. } |
| 1301 |
\msg_new:nnn { xtemplate } { declare-template-interface } |
| 1302 |
{ |
| 1303 |
Declaring~interface~for~template~'#2'~of~object~type~'#1'~ |
| 1304 |
\msg_line_context:. |
| 1305 |
} |
| 1306 |
\msg_new:nnn { xtemplate } { show-attribute } |
| 1307 |
{ |
| 1308 |
The~template~'#2'~of~object~type~'#1'~has~ |
| 1309 |
\tl_if_empty:nTF {#4} { no~#3. } { #3 : #4 } |
| 1310 |
} |
| 1311 |
\msg_new:nnn { xtemplate } { show-values } |
| 1312 |
{ |
| 1313 |
\tl_if_empty:nTF {#2} |
| 1314 |
{ The~instance~'#3'~ } |
| 1315 |
{ The~collection~ instance~'#3'~ (from~collection~'#2')~ } |
| 1316 |
of~object~type~'#1'~has~ |
| 1317 |
\tl_if_empty:nTF {#4} { no~values. } { values: #4 } |
| 1318 |
} |
| 1319 |
\cs_new_protected:Npn \DeclareObjectType #1#2 |
| 1320 |
{ \__xtemplate_declare_object_type:nn {#1} {#2} } |
| 1321 |
\cs_new_protected:Npn \DeclareTemplateInterface #1#2#3#4 |
| 1322 |
{ \__xtemplate_declare_template_keys:nnnn {#1} {#2} {#3} {#4} } |
| 1323 |
\cs_new_protected:Npn \DeclareTemplateCode #1#2#3#4#5 |
| 1324 |
{ \__xtemplate_declare_template_code:nnnnn {#1} {#2} {#3} {#4} {#5} } |
| 1325 |
\cs_new_protected:Npn \DeclareRestrictedTemplate #1#2#3#4 |
| 1326 |
{ \__xtemplate_declare_restricted:nnnn {#1} {#2} {#3} {#4} } |
| 1327 |
\cs_new_protected:Npn \DeclareInstance #1#2#3#4 |
| 1328 |
{ \__xtemplate_declare_instance:nnnnn {#1} {#3} { } {#2} {#4} } |
| 1329 |
\cs_new_protected:Npn \DeclareCollectionInstance #1#2#3#4#5 |
| 1330 |
{ \__xtemplate_declare_instance:nnnnn {#2} {#4} {#1} {#3} {#5} } |
| 1331 |
\cs_new_protected:Npn \DeclareInstanceCopy #1#2#3 |
| 1332 |
{ \__xtemplate_copy_instance:nnnn {#1} { } {#3} {#2} } |
| 1333 |
\cs_new_protected:Npn \EditTemplateDefaults #1#2#3 |
| 1334 |
{ \__xtemplate_edit_defaults:nnn {#1} {#2} {#3} } |
| 1335 |
\cs_new_protected:Npn \EditInstance #1#2#3 |
| 1336 |
{ \__xtemplate_edit_instance:nnnn {#1} { } {#2} {#3} } |
| 1337 |
\cs_new_protected:Npn \EditCollectionInstance #1#2#3#4 |
| 1338 |
{ \__xtemplate_edit_instance:nnnn {#2} {#1} {#3} {#4} } |
| 1339 |
\cs_new_protected:Npn \UseTemplate #1#2#3 |
| 1340 |
{ \__xtemplate_use_template:nnn {#1} {#2} {#3} } |
| 1341 |
\cs_new_protected:Npn \UseInstance #1#2 |
| 1342 |
{ \__xtemplate_use_instance:nn {#1} {#2} } |
| 1343 |
\cs_new_protected:Npn \UseCollection #1#2 |
| 1344 |
{ \__xtemplate_use_collection:nn {#1} {#2} } |
| 1345 |
\cs_new_protected:Npn \ShowTemplateCode #1#2 |
| 1346 |
{ \__xtemplate_show_code:nn {#1} {#2} } |
| 1347 |
\cs_new_protected:Npn \ShowTemplateDefaults #1#2 |
| 1348 |
{ \__xtemplate_show_defaults:nn {#1} {#2} } |
| 1349 |
\cs_new_protected:Npn \ShowTemplateInterface #1#2 |
| 1350 |
{ \__xtemplate_show_keytypes:nn {#1} {#2} } |
| 1351 |
\cs_new_protected:Npn \ShowTemplateVariables #1#2 |
| 1352 |
{ \__xtemplate_show_vars:nn {#1} {#2} } |
| 1353 |
\cs_new_protected:Npn \ShowInstanceValues #1#2 |
| 1354 |
{ \__xtemplate_show_values:nnn {#1} { } {#2} } |
| 1355 |
\cs_new_protected:Npn \ShowCollectionInstanceValues #1#2#3 |
| 1356 |
{ \__xtemplate_show_values:nnn {#1} {#2} {#3} } |
| 1357 |
\cs_new:Npn \IfInstanceExistTF #1#2 |
| 1358 |
{ \__xtemplate_if_instance_exist:nnnTF {#1} { } {#2} } |
| 1359 |
\cs_new:Npn \IfInstanceExistT #1#2 |
| 1360 |
{ \__xtemplate_if_instance_exist:nnnT {#1} { } {#2} } |
| 1361 |
\cs_new:Npn \IfInstanceExistF #1#2 |
| 1362 |
{ \__xtemplate_if_instance_exist:nnnF {#1} { } {#2} } |
| 1363 |
\cs_new_protected:Npn \KeyValue #1 {#1} |
| 1364 |
\cs_new_protected:Npn \AssignTemplateKeys |
| 1365 |
{ \__xtemplate_assignments_pop: } |
| 1366 |
\cs_new_protected:Npn \SetTemplateKeys #1#2#3 |
| 1367 |
{ \keys_set_known:nnN { template / #1 / #2 } {#3} \l__xtemplate_tmp_clist } |
| 1368 |
\cs_new_eq:NN \ShowTemplateKeytypes \ShowTemplateInterface |
| 1369 |
%% |
| 1370 |
%% |
| 1371 |
%% End of file `xtemplate.sty'. |