+ add =() subtemplates for params
[citadel.git] / webcit / subst.c
index 1b2301d72108d5384b3bae8f88ccc8488a832c55..215527a6185bbba3b1ebf3e9eb111d6be47ab45f 100644 (file)
@@ -537,6 +537,7 @@ void GetTemplateTokenString(WCTemplputParams *TP,
                            long *len)
 {
        StrBuf *Buf;
+       WCTemplputParams SubTP;
 
        if (TP->Tokens->nParameters < N) {
                lprintf(1, "invalid token. this shouldn't have come till here.\n");
@@ -569,6 +570,18 @@ void GetTemplateTokenString(WCTemplputParams *TP,
                *Value = _(TP->Tokens->Params[N]->Start);
                *len = strlen(*Value);
                break;
+       case TYPE_SUBTEMPLATE:
+               memset(&SubTP, 0, sizeof(WCTemplputParams *));
+               SubTP.Context = TP->Context;
+               SubTP.ContextType = TP->ContextType;
+               Buf = NewStrBuf();
+               DoTemplate(TKEY(N), Buf, &SubTP);
+               *Value = ChrPtr(Buf);
+               *len = StrLength(Buf);
+               /* we can't free it here, so we put it into the subst so its discarded later on. */
+               SVPUTBuf(TKEY(N), Buf, 0);
+               break;
+
        default:
                break;
 /*/todo log error */
@@ -813,6 +826,14 @@ TemplateParam *GetNextParameter(StrBuf *Buf, const char **pCh, const char *pe, W
                        ParamBrace = 1;
                }
        }
+       else if (*pch == '=') {
+               Parm->Type = TYPE_SUBTEMPLATE;
+               pch ++;
+               if (*pch == '(') {
+                       pch ++;
+                       ParamBrace = 1;
+               }
+       }
 
 
        if (*pch == '"')