Jason Sachs created FREEMARKER-68:

             Summary: Double-question mark operator does not properly test for 
                 Key: FREEMARKER-68
                 URL: https://issues.apache.org/jira/browse/FREEMARKER-68
             Project: Apache Freemarker
          Issue Type: Bug
          Components: engine
    Affects Versions: 2.3.23
            Reporter: Jason Sachs

The double-question mark operator doesn't work properly with some Jython 

It works properly with dicts.

It does not work properly with custom classes and triggers an item lookup.

Example setup: (I can't post a complete self-contained example, sorry)

Jython code called before FreeMarker template is rendered:

class VoodooDoll(object):
    def pinch(self):
        return "ouch"

model['test1'] = dict(voodooDoll=VoodooDoll())

FreeMarker template:
<#if test1.blah??>
blah present
<#if test1.voodooDoll??>
voodoo doll present
<#if test1.voodooDoll.pinch??>
voodoo doll pinch present
<#if test1.voodooDoll.hit??>
voodoo doll hit present

This produces the output

voodoo doll present
voodoo doll pinch present

so the first three {{#if}} tests work properly, but the fourth one causes this 

        - Failed at: #if test1.voodooDoll.hit??  [in template 
"source\\aux-files\\parameters.html.template" at line 58, column 1]


Caused by: TypeError: 'VoodooDoll' object is unsubscriptable

        at org.python.core.Py.TypeError(Py.java:235)

        at org.python.core.PyObject.__finditem__(PyObject.java:585)


This message was sent by Atlassian JIRA

Reply via email to