0

I am attempting to access the value of the current index of the list object dfeNumber, check if it is the first instance of this number, and add a visual break. I have never worked in Freemarker before (primarily the surrounding css), and have spent a bit of time looking through the Apache manual, but I cannot find an example of this kind of usage. I think it would look similar to:

<#assign msaReached=0>

<#list invName as invNames>

<#if ${dfeNumber[invNames_index]} = "900"> 
  <#assign msaReached++>
  <#if msaReached=1>
    -- do stuff --
  </#if>
</#if>

Would anyone be able to point me to an example of the syntax for usage in scenario? Any help would be greatly appreciated.

MISMajorDeveloperAnyways
  • 1,359
  • 3
  • 14
  • 20

1 Answers1

0

After some trial and error, I realized I never used this combination:

<#if dfeNumber[invNames_index] = "900">

Which worked.

MISMajorDeveloperAnyways
  • 1,359
  • 3
  • 14
  • 20
  • 1
    The documentation of `#if` says you need to put an "Expression evaluates to a boolean value" there, and then there's also a chapter about Expressions. Putting the two together, you get this, among others. Also, don't use old FreeMarker versions. For a while you get this error message, which would have save your time: `You can't use "${" here as you are already in FreeMarker-expression-mode. Thus, instead of ${myExpression}, just write myExpression. (${...} is only needed where otherwise static text is expected, i.e, outside FreeMarker tags and ${...}-s.)`. – ddekany Jul 27 '17 at 23:50
  • 1
    Also for future readers, if `dfeNumber[invNames_index]` is a number (as opposed to a string that looks like a number), then use `= 900`, without the `"`. (Also `==` is the canonical form, though `=` does the same here for backward compatibility.) – ddekany Jul 27 '17 at 23:53
  • Thank you for the clarification. I was able to locate the error message in the log files after redirecting them to a flat file vs. using the console. That is what clued me in to the correct syntax. Also, thanks for the tip about "==" as well. – MISMajorDeveloperAnyways Jul 28 '17 at 16:08