ngs-doo / TemplaterExamples

Creating reports in .NET and Java
https://templater.info
The Unlicense
48 stars 27 forks source link

Alternate nesting syntax #20

Closed polvoblanco closed 4 years ago

polvoblanco commented 4 years ago

Hi,

I'm currently reviewing Templater for inclusion in a Clojure project I am developing. For the most part it works really well out-the-box. However, Clojure's attribute naming is different to Java's and our users will be expecting to use the Clojure syntax not Java's. For example, a Clojure attribute, could be "some.dotted/attribute" or "some.more.dotted/attribute".  It is the dots in the namespace that is going to cause the confusion as they are also what it used to descend into nested values in Templater.

While, your system still functions as expected with the Clojure attribute names, it is confusing to the Document designer, i.e. "[[some.nested/collection.some.nested/value]]" it is unclear what is attribute and what is delimiting descending into the nested collection. It should be noted that attributes like "some.nested/value.attr" are also perfectly valid in Clojure, however as a convention dots aren't used after the slash.

So, is it possible to change the dot used to delimit descending into a nested value to another character, e.g. a colon ":"?

Many thanks,

Paul

zapov commented 4 years ago

Yes we could make navigation char configurable. I'll look into adding it to next version.

btw. are you referring just to descending into collection, or just regular navigation over properties?

polvoblanco commented 4 years ago

Hi, that's great news - I am referring to accessing nested data of any kind, be that a collection of nested data or a single associated record (essentially the ability to descend into a key/value map). We are not intending to make users aware of the ability to descend into an objects [Java] properties (if we do require something like Count then we will probably implement a meta DSL plugin for the purpose to keep the templates intuitive to non-programmers).

Many thanks, Paul

zapov commented 4 years ago

v5.0 has been released. Now you can specify custom navigation character