-// Spaghetti, technical debt, and an unmaintainable big mess.
-// No one knows how this works. This is why we started over with WebCit-NG.
+// This is a template substitution engine, which began with good intentions, but ended up becoming
+// more complex and unmaintainable than what it replaced. We are barely hanging on with this until
+// webcit-ng replaces webcit classic.
StrEscAppend(Target, Source, NULL, 0, 2);
break;
case 'X':
StrEscAppend(Target, Source, NULL, 0, 2);
break;
case 'X':
- StrEscAppend(Target, Source, NULL, 0, 0);
+ if (!IsEmptyStr(ChrPtr(Source))) {
+ StrEscAppend(Target, Source, NULL, 0, 0);
+ if (pFmt[1]) {
+ StrBufAppendBufPlain(Target, pFmt, -1, 1);
+ }
+ }
/* Primary Template set... */
StrBufPrintf(Dir, "%s/t", static_dirs[0]);
/* Primary Template set... */
StrBufPrintf(Dir, "%s/t", static_dirs[0]);
/* User local Template set */
StrBufPrintf(Dir, "%s/t", static_dirs[1]);
/* User local Template set */
StrBufPrintf(Dir, "%s/t", static_dirs[1]);
/* Debug Templates, just to be loaded while debugging. */
StrBufPrintf(Dir, "%s/dbg", static_dirs[0]);
/* Debug Templates, just to be loaded while debugging. */
StrBufPrintf(Dir, "%s/dbg", static_dirs[0]);
- while (GetNextHashPos(Templates[i],
- At,
- &KLen,
- &Key,
- &vTemplate) &&
- (vTemplate != NULL))
- {
+ while (GetNextHashPos(Templates[i], At, &KLen, &Key, &vTemplate) && (vTemplate != NULL)) {
if (TP->Tokens->nParameters >= 6) {
if (EvaluateConditional(Target, 0, state, TPP)) {
GetTemplateTokenString(Target, TP, 5, &AppendMe, &AppendMeLen);
if (TP->Tokens->nParameters >= 6) {
if (EvaluateConditional(Target, 0, state, TPP)) {
GetTemplateTokenString(Target, TP, 5, &AppendMe, &AppendMeLen);
}
else{
GetTemplateTokenString(Target, TP, 4, &AppendMe, &AppendMeLen);
}
else{
GetTemplateTokenString(Target, TP, 4, &AppendMe, &AppendMeLen);
- LogTemplateError(
- Target, "Conditional", ERR_NAME, TP,
- "needs at least 6 Params!");
+ LogTemplateError( Target, "Conditional", ERR_NAME, TP, "needs at least 6 Params!");
ChrPtr(Tmpl->FileName));
pTmpl = duplicate_template(Tmpl);
if(load_template(Target, pTmpl) == NULL) {
ChrPtr(Tmpl->FileName));
pTmpl = duplicate_template(Tmpl);
if(load_template(Target, pTmpl) == NULL) {
- StrBufAppendBufPlain(Target,
- pData,
- len - (pData - pS), 0);
+ StrBufAppendBufPlain(Target, pData, len - (pData - pS), 0);
TPtr->Tokens = pTmpl->Tokens[i];
TPtr->nArgs = pTmpl->Tokens[i]->nParameters;
TokenRc = EvaluateToken(Target, TokenRc, &TPtr);
TPtr->Tokens = pTmpl->Tokens[i];
TPtr->nArgs = pTmpl->Tokens[i]->nParameters;
TokenRc = EvaluateToken(Target, TokenRc, &TPtr);
syslog(LOG_WARNING, "Can't to load a template with empty name!\n");
StrBufAppendPrintf(Target, "<pre>\nCan't to load a template with empty name!\n</pre>");
return textPlainType;
syslog(LOG_WARNING, "Can't to load a template with empty name!\n");
StrBufAppendPrintf(Target, "<pre>\nCan't to load a template with empty name!\n</pre>");
return textPlainType;