Closed Kobus-Smit closed 5 months ago
The closest behavior you could have is if you implement some navigation plugin and write an extra tag just for this purpose. In that tag then you could set this root object. btw why do you need a root object? Navigation plugin provides parent object which is usually sufficient.
implement some navigation plugin and write an extra tag just for this purpose. In that tag then you could set this root object
Are there any examples available for this? Or some clues how to do it?
btw why do you need a root object?
Because my custom plugin removeIfEquals
need to check another tag's value, and if the same, do a remove:
For example, if the LEGAL_ENTITY and the ADDRESS_LINE_1 is the same, I just want to show the LEGAL_ENTITY:
[[LEGAL_ENTITY]:removeIfBlank]
[[ADDRESS_LINE_1]:removeIfBlank:removeIfEquals(LEGAL_ENTITY)]
similar to your mentioned example, "another tag/field should be used to display the appropriate value."
[[objectA.fieldA]:missing(objectB.fieldB)]
It works fine in my custom app that passes the values (as a Dictionary<string, object> Data
with tag names & values) on to the plugin, but I want that plugin to also work when launched from the Templater Editor.
Navigation plugin provides parent object which is usually sufficient.
I do not want the parent object, I want the root object so I can get access to some other the other fields.
You can find several navigation plugins here: https://github.com/ngs-doo/TemplaterExamples/blob/master/Intermediate/WordTables/src/Program.cs#L173 and here: https://github.com/ngs-doo/TemplaterExamples/blob/5b9f6aa347c8cad627da8cf21c911bb88361b0c7/Advanced/DepartmentReport/src/Program.cs#L115
One way to implement this exact use case would be to have something like
[[ADDRESS_LINE_1:nullIfEquals(LEGAL_ENTITY)]:removeIfBlank]
And then implement this nullIfEquals plugin to check on the parent object if its property LEGAL_ENTITY is of the same value and just return null in that case. After that removeIfBlank would remove it as expected.
Hacky way to save root object would be
[[some_field:save_object]]
where when detected save_object navigation plugin you would save the parent object for use in other plugins
Your suggestion worked for us, thanks @zapov
Hi @zapov
I've implemented a custom plugin where my app makes the root object available to my plugin, similar to
missing()
in the AlternativeProperty exampleI also want this custom plugin to work from the Templater Editor, when I select a JSON file. How do I make the root object available to my custom plugin from the
TemplaterEditor
class?