aboutsummaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/eachdo.c13
-rw-r--r--src/engine/engine.c2
2 files changed, 13 insertions, 2 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);
diff --git a/src/engine/engine.c b/src/engine/engine.c
index 683d39b..d101791 100644
--- a/src/engine/engine.c
+++ b/src/engine/engine.c
@@ -108,7 +108,7 @@ engine_ingest(char **buffer, bool is_template)
if (is_template && !strcmp(operands->source, "page"))
skip++;
else
- handle_eachdo(buffer, match, directive);
+ handle_eachdo(buffer, match, directive, engine->config);
break;
}