Hello,
I got an error when doing the comparizion in FTL, but
once I change the data source from TDD to CSV, and
specified prices with 'n', it works fine.
Not sure it is a bug or not, but i think FMPP is
important to test and debug the FTL design, so i
report it.
Best Regards
Ray Linn
************config.fmpp*************************
sourceRoot: src
outputRoot: out
logFile: log.fmpp
modes: [
copy(common/**/*.*, resource/*.*)
execute(*.ftl)
ignore(templates/*.*, .project, **/*.xml, xml/*.*,
*.js)
]
replaceExtensions: [ftl, html]
sourceEncoding: UTF-8
data: {
tdd(../data/product.tdd)
tdd(../data/animals.tdd,UTF-8)
}
***********animals.tdd************************
{
animals: {
mouse:{size:"small", price:50}
elephant:{ size:"large", price:5000}
python:{size:"medium", price:3000}
}
whatno: {
fruits: ["orange","banana"]
}
}
*****************price.ftl*********************
<html>
<head>
<title>Welcome!</title>
</head>
<body>
<ul>
<#if animals.python.price gt 3000.0>
${animals.python.price} is expensive
</#if>
</ul>
</body>
</html>
***************Error.MSG**********************
The cause of aborting was:
Error when processing this file: price.ftl
freemarker.template.TemplateException: The only legal
comparisons are between
two numbers, two strings, or two dates.
Left hand operand is a
freemarker.ext.beans.StringModel
Right hand operand is a
freemarker.template.SimpleNumber
--- Java stack trace: ---
The only legal comparisons are between two numbers,
two strings, or two dates.
Left hand operand is a
freemarker.ext.beans.StringModel
Right hand operand is a
freemarker.template.SimpleNumber
FMPP logs
Logged In: YES
user_id=546667
What a ugly fat bug you have found! The problem is with the
TDD parser, that forces the type of every values to string
that are inside {...}. BTW, the outermost {...} is redundant
in your TDD file example; if you remove that, then it will
work. Still, it's a bug, and it can still affect you if
later you will have a key-value pair where the value is a
hash. So here is the hotfix (replace fmpp.jar with this):
http://fmpp.sourceforge.net/qfix/fmpp.jar
This fix will be included in FMPP 0.9.12. Time to do that
release...
Logged In: YES
user_id=546667
Originator: NO
Fix released with FMPP 0.9.12