Nustache icon indicating copy to clipboard operation
Nustache copied to clipboard

XPath functions in templates

Open BillVelasquez opened this issue 7 years ago • 1 comments

This is a question, not an issue:

In Nustache you can use an XML document as the data for rendering, and then you can use XPath expressions that return nodes in the templates, like {{parent/child/node}}

Is it possible to use XPath functions in the templates?

It'll be really powerful to use something like {{sum(i­tems/price)}}

BillVelasquez avatar Aug 30 '17 20:08 BillVelasquez

That currently isn't something that is offered. You could implement something similar by creating a ValueGetterFactory and ValueGetter looking at XmlNodes and then compiling the expression and trying to run it. Hopefully this gives you the right direction.

Romanx avatar Aug 31 '17 12:08 Romanx