feat: add include functionality to support modular template composition

Implement the `include` directive that allows embedding external template files into the current template at render time. This enables code reuse and separation of concerns by letting templates import shared components like headers, footers, or partials. The feature parses include statements, resolves file paths relative to the template root, and recursively renders the included content within the parent template's variable scope.
This commit is contained in:
2025-11-23 14:23:59 +00:00
parent 77beada5a6
commit cfab51abd8
9 changed files with 394 additions and 15 deletions
+18
View File
@@ -0,0 +1,18 @@
int add(int a, int b) {
return a + b;
}
int subtract(int a, int b) {
return a - b;
}
int multiply(int a, int b) {
return a * b;
}
int divide(int a, int b) {
if (b == 0) {
return 0;
}
return a / b;
}
+19
View File
@@ -0,0 +1,19 @@
int string_length(char *s) {
return strlen(s);
}
char* string_upper(char *s) {
return upper(s);
}
char* string_lower(char *s) {
return lower(s);
}
int string_contains(char *haystack, char *needle) {
int pos = strpos(haystack, needle);
if (pos >= 0) {
return 1;
}
return 0;
}
+14
View File
@@ -0,0 +1,14 @@
#include "math_lib.rc"
#include "string_lib.rc"
int is_even(int n) {
int half = divide(n, 2);
return multiply(half, 2) == n;
}
int is_odd(int n) {
if (is_even(n)) {
return 0;
}
return 1;
}