Skip to content

feat: support merging frontmatter with tp.file.include#1698

Open
AndyEveritt wants to merge 10 commits intoSilentVoid13:masterfrom
AndyEveritt:fix-mergefrontmatter
Open

feat: support merging frontmatter with tp.file.include#1698
AndyEveritt wants to merge 10 commits intoSilentVoid13:masterfrom
AndyEveritt:fix-mergefrontmatter

Conversation

@AndyEveritt
Copy link
Copy Markdown
Contributor

Same as #1643 but changed the backwards compatibility of current_functions_object to be identical to previous behaviour

Copilot AI review requested due to automatic review settings January 29, 2026 16:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for merging frontmatter when using tp.file.include, enabling nested templates to contribute their frontmatter to the final output. This is a continuation of PR #1643 with improved backwards compatibility for current_functions_object.

Changes:

  • Adds frontmatter tracking and merging throughout the template parsing pipeline
  • Refactors internal functions to use a stack-based approach for function object management
  • Implements frontmatter extraction and merging for included templates

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/core/Templater.ts Adds frontmatter field to RunningConfig, implements function object stack management, and integrates frontmatter merging into template parsing and file operations
src/core/functions/internal_functions/file/InternalModuleFile.ts Modifies generate_include to extract and merge frontmatter from included files, returning only content without frontmatter
src/core/functions/internal_functions/InternalFunctions.ts Refactors module lifecycle to create new module instances per template parse instead of reusing them, enabling proper per-template state management
tests/main.test.ts Updates test configuration to include the new required frontmatter field
docs/documentation.toml Updates documentation for tp.file.include to describe the frontmatter merging behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/functions/internal_functions/InternalFunctions.ts Outdated
Comment thread src/core/Templater.ts Outdated
@Fred-Vatin
Copy link
Copy Markdown

Is there any obstacles preventing this PR to be finally merged ?

@AndyEveritt
Copy link
Copy Markdown
Contributor Author

I'm not sure why it isn't being merged tbh. I've made a release so you can just install that in your Obsidian repo if you want to use it.
https://github.com/AndyEveritt/Templater/releases/tag/2.18.1-1698

It's what I've been doing since September and it has been working fine for me on desktop and mobile

@Zachatoo
Copy link
Copy Markdown
Collaborator

I did a test with the example from #1695 and it still isn't working with your changes, I get an empty object instead of a populated functions object and it fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants