Data Models

Index Model

Another thing that lists can do is provide a way of indexing into a given point in the list. To support this, the TemplateIndexModel interface can be used:

public TemplateModel getAtIndex(long index)
                  throws TemplateModelException;

The above method is used by FM-Classic when a template wants to index directly into a list. We pass in a long rather than an int to match the precision FM-Classic uses for its number models. If in practise, you templates only use the foreach or list syntax, this interface is not required.