Skip to content

META BIND BUTTON BREAKS TEMPLATE WHEN LAUNCHED WITH A PREDEFINED VALUE #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 of 8 tasks
timcrouse opened this issue Apr 19, 2025 · 5 comments
Closed
3 of 8 tasks
Labels
bug Undesired behavior caused by this plugin

Comments

@timcrouse
Copy link

Please fill out these Check-boxes

  • I checked for existing similar issues
  • I checked that the plugin is up to date
  • The issue persists with all other plugins and themes disabled

Plugin Version

1.4.1

This Issue Occurs on

  • Windows
  • Linux
  • macOS
  • Android
  • iOS

Debug Info

If I use a metabind radio button set to define a YAMLE parameter used to define a dataview query filter, the template malfunctions.  Once the template breaks, simply removing the metabind code does not clear the issue; I have to revert to the previous template to get things working again.   The template defines YAML properties at the top of the template code.  Without the Metabind code in the template, each of the YAMLs is created as expected when the template is used to create a new file based on the directory assignment.  When I add the meta bind code and run the template, many of the YAMLs are omitted, and only the last two are created.  Once this happens, the template is trashed, and simply using Ctrl+Z to go back a few steps does not clear the issue.


beginning of template code:

<%*
// RETRIVE USER DEFINED FILE NAME WHEN FILE IS BEING CREATED
// A NICE EFFECT OF CREATING A VARIABLE FOR THE FILE NAME IS THAT
// WE CAN GET ACCESS TO THE VARIABLE ANYWHERE IN THE NOTE.
const newFileName = await tp.system.prompt("Enter File Name: ");
// TEMPLATER CANNONT DIRECTLY EDIT YAML DATA.  AS SUCH TO GET A YAML
// PROPERTY OF "NAME" ESTABLISHED WE BUILD A NEW YAML FRONT MATTER AREA
// THIS GIVES US ACCESS TO THE NAME PROPERTY FOR DATA QUERIES
if (newFileName) {
tR += `---
NAME: ${newFileName}
COMPANY:
LOCATION:
PHONE:
EMAIL:
POC_ID_TAG:
ASSOC_PROJ_TAGS:
PROJ_STATUS_QUERY: ALL
---
`;
await tp.file.move("/01 - SUPPORT FILES/POCs/" + newFileName);
}
%>

METABIND RADIO BUTTON CODE BLOCK (I have tried not predefining a selection and have been attempting to enable a selection AND ensure the YAML param matches the selection, but neither works).

**PROJECT LIST QUERY FILTER**
-bind
INPUT[select(option(ALL), option(ACTIVE), option(COMPLETE)):PROJ_STATUS_QUERY]

Describe the Issue

If I use a metabind radio button set to define a YAMLE parameter used to define a dataview query filter, the template malfunctions. Once the template breaks, simply removing the metabind code does not clear the issue; I have to revert to the previous template to get things working again. The template defines YAML properties at the top of the template code. Without the Metabind code in the template, each of the YAMLs is created as expected when the template is used to create a new file based on the directory assignment. When I add the meta bind code and run the template, many of the YAMLs are omitted, and only the last two are created. Once this happens, the template is trashed, and simply using Ctrl+Z to go back a few steps does not clear the issue.

beginning of template code:

<%*
// RETRIVE USER DEFINED FILE NAME WHEN FILE IS BEING CREATED
// A NICE EFFECT OF CREATING A VARIABLE FOR THE FILE NAME IS THAT
// WE CAN GET ACCESS TO THE VARIABLE ANYWHERE IN THE NOTE.
const newFileName = await tp.system.prompt("Enter File Name: ");
// TEMPLATER CANNONT DIRECTLY EDIT YAML DATA. AS SUCH TO GET A YAML
// PROPERTY OF "NAME" ESTABLISHED WE BUILD A NEW YAML FRONT MATTER AREA
// THIS GIVES US ACCESS TO THE NAME PROPERTY FOR DATA QUERIES
if (newFileName) {
tR += `---
NAME: ${newFileName}
COMPANY:
LOCATION:
PHONE:
EMAIL:
POC_ID_TAG:
ASSOC_PROJ_TAGS:
PROJ_STATUS_QUERY: ALL

`;
await tp.file.move("/01 - SUPPORT FILES/POCs/" + newFileName);
}
%>

METABIND RADIO BUTTON CODE BLOCK (I have tried not predefining a selection and have been attempting to enable a selection AND ensure the YAML param matches the selection, but neither works).

PROJECT LIST QUERY FILTER

INPUT[select(option(ALL), option(ACTIVE), option(COMPLETE)):PROJ_STATUS_QUERY]

BROKE - TMP - POC.md
TMP - POC.md

TMP - POC.md

Steps to Reproduce

USING THE TEMPLATER PLUGIN: ASSIGN A TEMPLATE TO A DIRECTORY
ADD THE META BIND CODE TO THE TEMPLATE
CREATE A NEW FILE
NOTICE HOW MANY OF THE TAGS ARE NOT CREATED
REMOVE THE META BIND CODE
CREATE NEW FILE
TAGS ARE STILL NOT CREATED, ONLY THE LAST TWO GET CREATED.

IF THE METABIND CODE IS NOT ADDED, THE TEMPLATE SEEMS TO WORK AS INTENDED

Expected Behavior

APPLY A VALUE TO A YAML PROPERTY

@timcrouse timcrouse added the bug Undesired behavior caused by this plugin label Apr 19, 2025
@mProjectsCode
Copy link
Owner

I am not quite sure I understood your issue right, but if a template already has a frontmatter block, your templater code won't add new properties to it. It seems to me you need different templater code for setting properties in your template. If you want meta bind inputs to do nothing in your template file, you can add the template folder to the excluded folders in the plugins settings.

PS: Please don't use caps everywhere, it makes it difficult to read. :)

@timcrouse
Copy link
Author

  1. Templater code is being used inside the template to create the fronmatter YAML. There is no defined front matter YAML before the template code. Sorry for all the caps those are comments that were already in the code.

  2. For clarity the work-flow is to use templater's directory assignment feature to create new notes. It is not to start manually editing a note then apply a template to it.

@timcrouse
Copy link
Author

timcrouse commented Apr 20, 2025

Issue resolved

The issue is related to templater code located at the top of a template. The initial function of the templater code is to ask the user for the name of the file to create. And another function of the templater code is to create the YAML front matter on the fly. Having existing YAML front matter in a file prevents the templater code that requests the file name from running.

The issue was that the meta-bind radio button setup in the template was predefined (Eg a value was selected). This forced a YAML to be created when the new file is created. The creation of the YAML from the meta-bind function takes precedence over the templater code for some reason, in other words when the new note creation is initiated the first thing that happens is the meta-bind function creates the missing YAML which then blocks the templater code of asking for the file name from running.

The work around is to have the meta-bind function in the template in an undefined state. In that way it does not create a YAML entry.

@timcrouse
Copy link
Author

timcrouse commented Apr 27, 2025 via email

@timcrouse
Copy link
Author

timcrouse commented Apr 27, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behavior caused by this plugin
Projects
None yet
Development

No branches or pull requests

2 participants