diff options
Diffstat (limited to 'src/smp/builtins.py')
-rw-r--r-- | src/smp/builtins.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/smp/builtins.py b/src/smp/builtins.py index 537da37..f06df4e 100644 --- a/src/smp/builtins.py +++ b/src/smp/builtins.py @@ -90,7 +90,9 @@ def smp_builtin_add_metadata(macro_processor, metadata: dict[str, Any], overwrit def smp_builtin_include_file(macro_processor, filename): - return _smp_builtin_read(macro_processor, filename, template_content=None) + return _smp_builtin_read( + macro_processor, filename, template_content=None, inline=True + ) def smp_builtin_parse_leading_yaml(macro_processor, content): @@ -203,7 +205,7 @@ def smp_builtin_template(macro_processor, template, content): return _smp_builtin_read(macro_processor, template, template_content=content) -def _smp_builtin_read(macro_processor, filename, template_content=None): +def _smp_builtin_read(macro_processor, filename, template_content=None, inline=False): macro_processor._enter_file_frame(filename, 0, template_content) with open(filename, "r") as f: file_content = f.read() @@ -214,13 +216,13 @@ def _smp_builtin_read(macro_processor, filename, template_content=None): smp_builtin_add_metadata(macro_processor, metadata, overwrite=True) extension = os.path.splitext(filename)[1][1:] or "" - macro_processor._define_macro_with_prefix("target_file_extension", extension) + if not inline: + macro_processor._define_macro_with_prefix("target_file_extension", extension) if template_content is not None: macro_processor._get_macro_with_prefix("template_stack").append(filename) macro_processor.macros["CONTENT"] = template_content - # content = macro_processor.process_input(file_content, file=filename) content = file_content if (template := macro_processor._get_metadata("template")) is not None: |