Skip to content

Commit

Permalink
Re-introduce \IfInstanceExist(TF)
Browse files Browse the repository at this point in the history
This reverts commit 10a330e.
  • Loading branch information
josephwright committed Feb 16, 2024
1 parent d455648 commit 41f33bc
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
4 changes: 4 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================

2024-02-15 Joseph Wright <Joseph.Wright@latex-project.org>
* lttemplates.dtx
Re-introduce \IfInstanceExist(TF)

2024-01-30 David Carlisle <David.Carlisle@latex-project.org>
* ltclass.dtx: check that \RequirePackage, \documentclass, \usepackage
and related commands are at top level (gh/1185)
Expand Down
15 changes: 14 additions & 1 deletion base/lttemplates.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
%<*driver>
% \fi
\ProvidesFile{lttemplates.dtx}
[2024-02-11 v1.0a LaTeX Kernel (Prototype document functions)]
[2024-02-15 v1.0b LaTeX Kernel (Prototype document functions)]
% \iffalse
\documentclass{l3doc}
\GetFileInfo{lttemplates.dtx}
Expand Down Expand Up @@ -2653,6 +2653,19 @@
% \end{macro}
% \end{macro}
%
% \begin{macro}{\IfInstanceExistT, \IfInstanceExistF, \IfInstanceExistTF}
% \changes{2024-02-15}{v1.0b}{New macros}
% More direct translation.
% \begin{macrocode}
\cs_new:Npn \IfInstanceExistTF #1#2
{ \@@_if_instance_exist:nnTF {#1} {#2} }
\cs_new:Npn \IfInstanceExistT #1#2
{ \@@_if_instance_exist:nnT {#1} {#2} }
\cs_new:Npn \IfInstanceExistF #1#2
{ \@@_if_instance_exist:nnF {#1} {#2} }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\KeyValue}
% Simply dump the argument when executed: this should not happen.
% \begin{macrocode}
Expand Down
26 changes: 26 additions & 0 deletions base/testfiles-lttemplates/lttemplates003.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,32 @@
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 17
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\TEST{Testing~instances:~existance~check}{

\IfInstanceExistTF {test} {nono} % instance unknwon, ok
{\typeout{Yes}} {\typeout{No}}

\IfInstanceExistTF {missingobjecttype} {nono} % objecttype unknown, ok
{\typeout{Yes}} {\typeout{No}}

\group_begin:

\DeclareInstance {test} {myinstance} {tname2} {}

\IfInstanceExistTF {test} {myinstance} % test inside group, ok
{\typeout{Yes}} {\typeout{No}}

\group_end:

\IfInstanceExistTF {test} {myinstance} % test outside group
{\typeout{Yes}} {\typeout{No}} % no longer defined, ok

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 18
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
14 changes: 11 additions & 3 deletions base/testfiles-lttemplates/lttemplates003.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,15 @@ The template 'tname16' of type 'test' has variable mapping:
l. ...}
============================================================
============================================================
TEST 17: Testing instances: declare instance
TEST 17: Testing instances: existance check
============================================================
No
No
Yes
No
============================================================
============================================================
TEST 18: Testing instances: declare instance
============================================================
! LaTeX template Error: The template 'never-defined' of type 'test' is unknown
(template) or has no implementation.
Expand All @@ -317,7 +325,7 @@ huh
(Y-99)
============================================================
============================================================
TEST 18: Edit template defaults
TEST 19: Edit template defaults
============================================================
Defining key template/test/tname17/key on line ...
Defining key template/test/tname17/key/unknown on line ...
Expand Down Expand Up @@ -368,7 +376,7 @@ l. ...}
The key 'wrong' was not declared in the interface for the current template.
============================================================
============================================================
TEST 19: Edit instance values
TEST 20: Edit instance values
============================================================
The instance 'myinstance' of type 'test' has values:
> key => A
Expand Down

0 comments on commit 41f33bc

Please sign in to comment.