-
Notifications
You must be signed in to change notification settings - Fork 87
Description
In other implementations of mustache there is the ability to write a selector into an array by the index. Ex: items.0.name. This doesn't seem possible with the golang implementation. I understand how it is potentially free in JS, but it would require extra effort in golang. Is this something that could be supported in the future?
Similar requests by other libraries (with mixed results):
Python: defunkt/pystache#196
C#: DanieleScipioni/Mustache#2
Erlang: soranoba/bbmustache#41
Swift: groue/GRMustache.swift#2
Alternative idea: Methods that support params.
golang's text/template supports index lookup with functions.
{{ (index .items 0).Name }}
try it: https://play.golang.org/p/dgIMARysMOX
It looks like this library already supports functions on the struct, but it didn't seem to support params. If it did, then a getter could be added as needed.