wbond / pybars3

Handlebars.js template support for Python 3 and 2
GNU Lesser General Public License v3.0
179 stars 46 forks source link

Negative int literals don't work #10

Closed viernullvier closed 9 years ago

viernullvier commented 9 years ago

I just ran into a general problem: When using literals in a template, negative int values are evaluated to None instead of their actual value.

Example:

from pybars import Compiler
compiler = Compiler()

def get_type(self, value):
    return str(type(value))
helpers = {'type': get_type}

source = u'{{{type "string"}}} {{{type 1}}} {{{type -1}}}'
template = compiler.compile(source)
print template({}, helpers=helpers)
>>> <type 'str'> <type 'int'> <type 'NoneType'>
wbond commented 9 years ago

Fixed by e359300bf0f01c4529b23a8e936b106b0a5ed6e0