I have defined the macro \getdocvar
that retrieves a value from a property list given it is key. It has an optional argument which is a list of key-values. At the moment only the transform
key is defined. I want to store in this key a macro to be applied to the value retrieved by \getdocvar
.
\keys_define:nn { docvar/get }
{
transform .tl_set:N = \l_docvar_tranformation_tl,
}
The name of the macro is stored as a token list.
\cs_new_protected:Npn \docvar_get_properties:n #1
{
\group_begin:
\keys_set:nn { docvar/get } { #1 }
\group_end:
}
Now, if \getdocvar
has no optional argument, the value of the prop
is retrieved, but I have no idea how to apply a macro to #2
based on the name.
\DeclareDocumentCommand \getdocvar {o m}{
\IfNoValueTF { #1 }
{
\prop_get:NVN \g_docvar_values_prop #2 \g_tmpa_tl
\tl_use:N \g_tmpa_tl
}
{
\docvar_get_properties:n {#1}
%%% MISSIn CODE to cronstruct a macro from transform key
}
Any hit to how this may be done.
The full sequence of using this macro is
\definedocvar{title}
\setdocvar{title}{This is my title}
\getdocvar{title}
% This should print:
This is my title
\getdocvar[transform=MakeUppercase]{title}
% This should print:
\MakeUppercase{This is my title}
\getdocvar
supposed to be called? – egreg Mar 31 '17 at 10:25