javafreemarkerliferay-7

does not render the template created with Liferay I get the following error


Syntax error in template "37675#37715#76503" in line 32, column 46: You can't use ${...} (an interpolation) here as you are already in FreeMarker-expression-mode. Thus, instead of ${myExpression}, just write myExpression. (${...} is only used where otherwise static text is expected, i.e., outside FreeMarker tags and interpolations, or inside string literals.)

${request}<#if searchResultsPortletDisplayContext.getDocuments()?has_content>
<div class="page-general__products">
    <div class="container">
        <div class="text">
            <h1>¿Lorem Ipsum?</h1>
            <p>Lorem Ipsum</p>
        </div>
        <div class="row">
           
            <#list searchResultsPortletDisplayContext.getDocuments() as entry>
            <#assign 
                    jls = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryService")
                   entryClassPK = entry.getField("entryClassPK").getValue()?number
                   entryClassName = entry.getField("entryClassName").getValue()
                    journalArticle = entry.getField("articleId_String_sortable").getValue()
                    curEntry = jls.getEntry(entryClassName,entryClassPK)
                /> 
                
               
                
                <#assign fields = curEntry.getAssetRenderer().getDDMFormValuesReader().getDDMFormValues().getDDMFormFieldValues()
                esGrande = fields[0].getValue().getString(locale)
                />

       
          <#if esGrande=="true">   
          <div class="col-md-4 col-lg-3">
          <#else>
          <div class="col-md-8 col-lg-6">
          </#if>
          <#assign
                    assetRenderer = curEntry.${entry.getContent()}${entry.getCreationDateString()}${entry.getCreatorUserName()}()
                    journalArticle = assetRenderer.getAssetObject()/>
                <@liferay_journal["journal-article"]
                    articleId=journalArticle.getArticleId()
                    ddmTemplateKey="76229"
                    groupId=journalArticle.getGroupId()/>
                </div> 
                </#list>
        </div>    
    </div> 
</div>
</#if>

    enter code here

Solution

  • The error message is self-explanatory, just use:

    assetRenderer = entry.getAssetRenderer()

    Instead of: assetRenderer = curEntry.${entry.getContent()}

    You can't use ${...} in the FreeMarker-expression-mode.