11-- ----------------------------------------------------------------------------
22-- Templates Parser --
33-- --
4- -- Copyright (C) 2003-2018 , AdaCore --
4+ -- Copyright (C) 2003-2022 , AdaCore --
55-- --
66-- This library is free software; you can redistribute it and/or modify --
77-- it under terms of the GNU General Public License as published by the --
@@ -103,6 +103,8 @@ package body Filter is
103103 Web_NBSP_Token : aliased constant String := " WEB_NBSP" ;
104104 Wrap_Token : aliased constant String := " WRAP" ;
105105 Yes_No_Token : aliased constant String := " YES_NO" ;
106+ Default_Token : aliased constant String := " DEFAULT" ;
107+ Alternate_Token : aliased constant String := " ALTERNATE" ;
106108
107109 -- Filters Table
108110
@@ -128,6 +130,9 @@ package body Filter is
128130 Add_Param =>
129131 (Add_Param_Token'Access , Add_Param'Access ),
130132
133+ Alternate =>
134+ (Alternate_Token'Access , Alternate'Access ),
135+
131136 BR_2_EOL =>
132137 (BR_2_EOL_Token'Access , BR_2_EOL'Access ),
133138
@@ -146,6 +151,9 @@ package body Filter is
146151 Contract =>
147152 (Contract_Token'Access , Contract'Access ),
148153
154+ Default =>
155+ (Default_Token'Access , Default'Access ),
156+
149157 Del_Param =>
150158 (Del_Param_Token'Access , Del_Param'Access ),
151159
@@ -343,6 +351,28 @@ package body Filter is
343351 end if ;
344352 end Add_Param ;
345353
354+ -- -------------
355+ -- Alternate --
356+ -- -------------
357+
358+ function Alternate
359+ (S : String;
360+ C : not null access Filter_Context;
361+ P : Parameter_Data := No_Parameter) return String
362+ is
363+ pragma Unreferenced (C);
364+ begin
365+ if P = No_Parameter then
366+ raise Template_Error with " missing parameter for ALTERNATE filter" ;
367+ end if ;
368+
369+ if S = " " then
370+ return " " ;
371+ else
372+ return To_String (P.S);
373+ end if ;
374+ end Alternate ;
375+
346376 -- ------------
347377 -- BR_2_EOL --
348378 -- ------------
@@ -570,6 +600,28 @@ package body Filter is
570600 end if ;
571601 end Contract ;
572602
603+ -- -----------
604+ -- Default --
605+ -- -----------
606+
607+ function Default
608+ (S : String;
609+ C : not null access Filter_Context;
610+ P : Parameter_Data := No_Parameter) return String
611+ is
612+ pragma Unreferenced (C);
613+ begin
614+ if P = No_Parameter then
615+ raise Template_Error with " missing parameter for DEFAULT filter" ;
616+ end if ;
617+
618+ if S = " " then
619+ return To_String (P.S);
620+ else
621+ return S;
622+ end if ;
623+ end Default ;
624+
573625 -- -------------
574626 -- Del_Param --
575627 -- -------------
0 commit comments