Arrays FreeMarker和array如何将项目分配到特定位置

Arrays FreeMarker和array如何将项目分配到特定位置,arrays,freemarker,Arrays,Freemarker,----代码js---- 如果可以在freemarker中这样做,您可以教我一个例子 <#macro cuenta d > <#assign posicion=0> <#assign arregloCuenta=[]> <#list args.array?split(",") as value> <#assign posicion=posicion+1> <#if d.properties["bchil

----代码js----

如果可以在freemarker中这样做,您可以教我一个例子

    <#macro cuenta d > 

<#assign posicion=0> 

<#assign arregloCuenta=[]> 

<#list args.array?split(",") as value> 

<#assign posicion=posicion+1> 

<#if d.properties["bchile:tipodoc"]?exists >

 <#if d.properties["bchile:tipodoc"] == value>

 <#assign arregloCuenta=["juan"]> 

<#assign arregloCuenta= arregloCuenta + ["felipe"]> ${args.array[0]} ${posicion} ${arregloCuenta[1]} </#if> </#if> </#list> </#macro> 

${args.array[0]}${posicion}${arregloCuenta[1]}

来自FreeMarker的常见问题解答:

FreeMarker模板语言不支持修改序列/哈希。它用于显示已计算的内容,而不是用于计算数据。保持模板简单。但不要放弃,你会看到下面的一些建议和技巧

下面还有一点:

例如,您希望以某种非常智能的方式显示关键字索引,其算法需要您创建和写入一些序列变量。然后你应该这样做(丑陋的情况有丑陋的解决方案…):


您可以阅读

中的完整条目,教我一个例子?这不是你的大学班或自由职业者。您必须向我们展示您尝试过的内容-1我尝试过这个和其他各种已经删除${args.array[0]}${posicion}${arregloCuenta[1]}的东西好的,您能告诉我您到底想要什么吗?你需要一个例子,你可以从数组中生成一些东西吗?我需要修改一个数组元素,给出在freemarker中的位置
    <#macro cuenta d > 

<#assign posicion=0> 

<#assign arregloCuenta=[]> 

<#list args.array?split(",") as value> 

<#assign posicion=posicion+1> 

<#if d.properties["bchile:tipodoc"]?exists >

 <#if d.properties["bchile:tipodoc"] == value>

 <#assign arregloCuenta=["juan"]> 

<#assign arregloCuenta= arregloCuenta + ["felipe"]> ${args.array[0]} ${posicion} ${arregloCuenta[1]} </#if> </#if> </#list> </#macro> 
<#assign calculatedResults =
'com.example.foo.SmartKeywordIndexHelper'?new().calculate(keywords)>
<#-- some simple algorithms comes here, like: -->
<ul>
  <#list calculatedResults as kw>
    <li><a href="${kw.link}">${kw.word}</a>
  </#list>
</ul> 
seq[0..pos-1] + ["New element"] + seq[pos+1..]