The intuitive (not working) solution
Here is a partial solution, which in theory should work all the way:
My command: `= "<code>command -i " + this.input_file + " -o " + this.output_file +"</code>"`
It utilises the Meta-bind plugin to produce the input field, and the Dataview plugin to produce the output. Sadly, the output is not refreshed due to the query not actually changing (only the date it relies on is changing). So that’s a bummer. In order for it to refresh you need to either close and re-open this file, or go back (and forward again) in file history.
Using Templater and Buttons as well
One way to counter this non-refreshing query thing is to use a combination of Templater and Buttons. This can be done in two ways, where either option requires that the button must be pressed.
In one version the button will replace a given line in the end note, so proper care needs to be taken that this line number doesn’t change (or the button will happily change whatever text is on that particular line. The other version just keeps on appending a new command line into your note, resulting in multiple commands, if you change the input often. The advantage of this latter variant is that it wont (accidentally) remove lines due to you shifting line numbers, which might happen with the first variant…
Here is a screendump with both options covered:
Notice how the
replace [37, 37] refers to the line number of the resulting line where the “input33123” file name is used. If you add lines in front of this button definitions, you’ll need to change 37 to whatever number it ends up on. Also see how in the latter variant, I’ve pressed the button a few times, so multiple lines are appended.
Both of these rely on a template which I’ve called
forum/f57426_command which resides in the
forum sub-folder of my templates folder, which contains this text:
<code>command -i <% tp.frontmatter.input_file %> -o <% tp.frontmatter.output_file %></code>
Code to generate the buttons
Here is the text version of the buttons. NB! Make sure to match
37 to the line number where you want your command to appear.
name Replace command
type line(37) template
name Append command
type append template
Using the Minimal theme this look like this in my setup:
You can of course change all text and formatting related to the various command outputs and template output as per your liking.
Hope this illustrates some of the possibilities and caveats related to input fields, and using that value within the same file.