}
/*
- * Merge the template so everyting else "just works".
+ * Merge the template so everything else "just works".
*/
static bool cf_template_merge(CONF_SECTION *cs, CONF_SECTION const *template)
{
return -1;
}
+ /*
+ * Allow in-line templates.
+ */
+ templatecs = cf_section_find(cf_item_to_section(cf_parent(parent)), "template", stack->buff[2]);
+ if (templatecs) {
+ parent->template = templatecs;
+ return 0;
+ }
+
parent_cs = cf_root(parent);
templatecs = cf_section_find(parent_cs, "templates", NULL);
*r = '\0';
*q = '\0';
next = cf_section_find(cs, p, r + 1);
+ if (!next && cs->template) next = cf_section_find(cs->template, p, r + 1);
*r = '[';
*q = ']';
} else {
*q = '\0';
next = cf_section_find(cs, p, NULL);
+ if (!next && cs->template) next = cf_section_find(cs->template, p, NULL);
*q = '.';
}
* section.
*/
cp = cf_pair_find(cs, p);
+ if (!cp && cs->template) cp = cf_pair_find(cs->template, p);
if (cp) {
cp->referenced = true; /* conf pairs which are referenced count as used */
return &(cp->item);
name = cf_section_name1(subcs);
if (unlang_compile_is_keyword(name)) goto invalid_name;
+ /*
+ * Skip inline templates, and disallow "template { ... }"
+ */
+ if (strcmp(name, "template") == 0) {
+ if (!cf_section_name2(subcs)) goto invalid_name;
+ continue;
+ }
+
instance = module_bootstrap(NULL, subcs);
if (!instance) return -1;