-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Comments
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. :) |
|
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. |
Any chance you could show me how to get the following to work:
Define two YAMLs
TMP_PATH
LOG_PATH
Access those defined paths in a meta-bind-button code block to declare the:
templateFile
FolderPath
The following is not working for me..........
```meta-bind-button
label: "CREATE A NEW PROJECT LOG"
icon: ""
hidden: false
class: ""
tooltip: ""
id: ""
style: default
actions:
- type: templaterCreateNote
templateFile: (#TMP_PATH) # Correct way to reference TMP_PATH
folderPath: (#LOG_PATH) # Correct way to reference LOG_PATH
openNote: true
```
Thanks in Advance
-Tim C.
…________________________________
From: Moritz Jung ***@***.***>
Sent: Sunday, April 20, 2025 9:24 AM
To: mProjectsCode/obsidian-meta-bind-plugin ***@***.***>
Cc: timcrouse ***@***.***>; Author ***@***.***>
Subject: Re: [mProjectsCode/obsidian-meta-bind-plugin] META BIND BUTTON BREAKS TEMPLATE WHEN LAUNCHED WITH A PREDEFINED VALUE (Issue #567)
Closed #567<#567> as completed.
—
Reply to this email directly, view it on GitHub<#567 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGW34IMXPV5RTUBOZJMQIVT22ONZTAVCNFSM6AAAAAB3ODPNVWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJXGMZTCMZRGYZDONA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Would you ,mind adding this to your examples:
```meta-bind-js-view
{TMP_PATH} as templatePath
{LOG_PATH} as logPath
---
const buttonString = `
~~~meta-bind-button
label: "📝 Create New Project Log"
icon: ""
hidden: false
class: "button-43"
tooltip: "Create a new note from template"
id: ""
style: primary
actions:
- type: templaterCreateNote
templateFile: ${context.bound.templatePath}
folderPath: ${context.bound.logPath}
openNote: true
~~~
`;
return engine.markdown.create(buttonString);
```
The next step in this is to figure out how to retrieve the YAML from a different file in the same location along with retrieving the eYAML from a file in a different location, baby steps 🙂
Best Regards
-Tim C.
…________________________________
From: Moritz Jung ***@***.***>
Sent: Sunday, April 20, 2025 9:24 AM
To: mProjectsCode/obsidian-meta-bind-plugin ***@***.***>
Cc: timcrouse ***@***.***>; Author ***@***.***>
Subject: Re: [mProjectsCode/obsidian-meta-bind-plugin] META BIND BUTTON BREAKS TEMPLATE WHEN LAUNCHED WITH A PREDEFINED VALUE (Issue #567)
Closed #567<#567> as completed.
—
Reply to this email directly, view it on GitHub<#567 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGW34IMXPV5RTUBOZJMQIVT22ONZTAVCNFSM6AAAAAB3ODPNVWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJXGMZTCMZRGYZDONA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Please fill out these Check-boxes
Plugin Version
1.4.1
This Issue Occurs on
Debug Info
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
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
The text was updated successfully, but these errors were encountered: