aboutsummaryrefslogtreecommitdiff
path: root/src/engine/eachdo.c
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-08-29 14:33:02 -0400
committerRaghuram Subramani <raghus2247@gmail.com>2025-08-29 14:33:02 -0400
commitf63235994855a3a6d71fb82f63b7b9d690ba5527 (patch)
tree4a28b22c1e3f870135a8ecc518ab3fc00e60ede8 /src/engine/eachdo.c
parent5c726117f22d27ce46b7efefe9da6e39346efa09 (diff)
engine: handle eachdo with page as source if file is not a template
Diffstat (limited to 'src/engine/eachdo.c')
-rw-r--r--src/engine/eachdo.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/engine/eachdo.c b/src/engine/eachdo.c
index 2d3ec4c..2b1cf07 100644
--- a/src/engine/eachdo.c
+++ b/src/engine/eachdo.c
@@ -159,6 +159,12 @@ handle_page_source(list_t *atoms,
list_t *directives,
config_t *config)
{
+ if (config == NULL) {
+ printf("EACHDO with page variables as a source will not work without "
+ "a config at the top of the file\n");
+ return;
+ }
+
list_t *nested_blocks
= unwrap(list_find_corresponding_value_from_ptr_wrapper(
config->keys, config->nested_config_values, trim(operands->key)));
@@ -186,7 +192,10 @@ handle_page_source(list_t *atoms,
* directive: Pointer to the directive struct
*/
void
-handle_eachdo(char **buffer, key_match_t *match, directive_t *directive)
+handle_eachdo(char **buffer,
+ key_match_t *match,
+ directive_t *directive,
+ config_t *config)
{
eachdo_operands_t *operands = directive->operands;
@@ -200,6 +209,8 @@ handle_eachdo(char **buffer, key_match_t *match, directive_t *directive)
if (!strcmp(operands->source, "resources"))
handle_file_source(atoms, operands, directives);
+ else if (!strcmp(operands->source, "page"))
+ handle_page_source(atoms, operands, directives, config);
else
printf("Unknown source: %s\n", operands->source);