New Properties and templater prompts and commands?

Hey, Alan,

Last time I incorporated your solution in a longer Templater Js script and it threw the usual merging issues pop-up on me (and added false field values as well, ostensibly because of timing issues in my script).
Used the MetaEdit way instead:

// Using the MetaEdit API's createYamlProperty function add the 'class' property with the value 'dg_uploaded'
const { createYamlProperty } = this.app.plugins.plugins["metaedit"].api;
const classPropertyName = 'class';
await createYamlProperty(classPropertyName, 'dg_uploaded', currentFile);
console.log("Added 'class' property with value 'dg_uploaded' in the current file.");

If anybody wants to use this, let me remind them that currently adding only a single property works reliably in MetaEdit. (See here.)

EDIT. Turns out this doesn’t work very well, either. Dang, these timing issues and then messing up and correcting YAML keys and values really cut into my days…

EDIT 2.
If adding single or multiple properties draws errors (because everybody’s scripts are different and note lengths can vary, not to mention CPU speed differences or other quirks), one very strange-sounding workaround would be to batch-create a dummy_key: dummy field line (or two) in every file using an outside of Obsidian search and replace method (like the one discussed here), then in the templater script we search and replace those dummies on demand, like so:

  // Replace some fields
  updatedContent = updatedContent.replace(/dg_upload_status:\sdown/g, 'class: dg_uploaded');
  updatedContent = updatedContent.replace(/unformatted⚪/g, 'formatted🟢');
2 Likes