schallis/pystache — comment on commit 6752d6e13e383841f8787f1d4b4e1317d81024f0
File:  line 0
By cjerdonek:

There are cases according to the [spec](https://github.com/mustache/spec/blob/master/specs/interpolation.yml) (in the section on sections) and the [mustache(5) manual](http://mustache.github.com/mustache.5.html) (in the subsection on "non-false values") where a string can be a valid element of the context stack. It can come up, for example, in cases like this:

template = '{{#person}}{{.}}{{/person}}'
context = {'person': 'John'}
expected = u'John'

Yes, I think there should be a more general solution to the problem. In the section on interpolation, the [spec](https://github.com/mustache/spec/blob/master/specs/interpolation.yml) makes a distinction between two cases: hashes and objects. Because of the case you raised, we don't want to consider strings "objects" -- even though in Python, just about everything is, strictly speaking, an object.

I think a possible solution might be to draw the line at built-in types. Anything that is an instance of a built-in type (an integer, string, list, tuple, etc.) could be considered, for Mustache purposes, not to be an object. On the other hand, instances of user-defined classes, for example, would be considered objects.