[MGNLMIGRATION-137] ftl-Migration: Improve code substitution for new areas - current scripts produce syntactically invalid freemarker templates Created: 18/Oct/12  Updated: 06/Dec/12  Resolved: 06/Dec/12

Status: Closed
Project: Migration 4.4 to 4.5 (closed)
Component/s: None
Affects Version/s: 1.1.4
Fix Version/s: 1.2

Type: Bug Priority: Major
Reporter: wolf bubenik Assignee: Robert Šiška
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Migros project


Template:
Acceptance criteria:
Empty
Date of First Response:

 Description   

ftl-files that contain wrapper HTML-tags and if-statements around new-Bars are processed incorrectly. Code like

[@cms.contentNodeIterator contentNodeCollectionName="linkList"]
    [@cms.includeTemplate /]
[/@cms.contentNodeIterator]

[#if mgnl.editMode]
    <li>
        [@cms.newBar contentNodeCollectionName="linkList" newLabel="${i18n['link.newLabel']}" paragraph="${def.subParagraphs}" /]
    </li>
[/#if]

is migrated to:

        [#--OLD  AREA
[@cms.contentNodeIterator  contentNodeCollectionName="linkList"]
    [@cms.includeTemplate  /]
[/@cms.contentNodeIterator]

[#if  mgnl.editMode]
    <li>
        [@cms.newBar  contentNodeCollectionName="linkList" newLabel="${i18n['link.newLabel']}" paragraph="${def.subParagraphs}" /]
AREA--][@cms.area  name = "linkList"  /]<p class="migration_warning">Please make sure that an area named linkList exists in your Magnolia configuration</p>
    </li>
[/#if]

leaving orphaned HTML-Tags (</li>) and if-statements (/#if) behind.

The migration could be improved to produce something like:

[#--OLD  AREA
[@cms.contentNodeIterator  contentNodeCollectionName="linkList"]
    [@cms.includeTemplate  /]
[/@cms.contentNodeIterator]
AREA--]
[@cms.area  name = "linkList"  /]<p class="migration_warning">Please make sure that an area named linkList exists in your Magnolia configuration</p>

[#if  mgnl.editMode]
    <li>
        [#--OLD  AREA [@cms.newBar  contentNodeCollectionName="linkList" newLabel="${i18n['link.newLabel']}" paragraph="${def.subParagraphs}" /] AREA--]
    </li>
[/#if]  


 Comments   
Comment by wolf bubenik [ 02/Nov/12 ]

Please note that there is a corresponding error in the generated area ftl. Code like

[#if [#--OLD   mgnl.editMode --]  cmsfn.editMode]
    <li>
    [#--OLD [@cms.newBar   contentNodeCollectionName="linkList" newLabel="${i18n['link.newLabel']}" paragraph="${def.subParagraphs}" /] --]

is produced - again with orphaned if and HTML-tags. As I see it

[\#if cmsfn.editMode]
   <li cms:add="bar"></li>
[/#if]

would be a better replacement.

Comment by Jan Haderka [ 02/Dec/12 ]
     /*public static void main(String args[]) throws Exception {
         //File testTemplate = new File("/home/rsiska/aperto/migros-common-templating-MG-4.5/src/main/resources/mgnl-files/templates/migros-common-templating/paragraphs/features/faq.ftl");
         //File testTemplate = new File("/home/rsiska/4.5.4/ee/apache-tomcat-6.0.32/webapps/magnoliaAuthor/templates.bak/migros-common-templating/paragraphs/teaser/infoTeaser.ftl");
-        File testTemplate = new File("/home/rsiska/migration/coop-internet-migration-to-4.5/coop-internet-webapp/src/main/webapp/coop-internet-website/templates/mobile/mobile.ftl");
+        File testTemplate = new File("/home/rsiska/migration/coop-internet-migration-to-4.5/coop-internet-webapp/src/main/webapp/coop-internet-website/paragraphs/content/imageMap.ftl");

Pls keep private tests out of the public code base.

+    
+    /**
+     * Half-deep constructor.
+     * @param orig
+     */
+    public TemplateTree(TemplateTree orig) {

What is half-deep constructor? Whole business of TemplateTree class and it's numbering is unclear. Document what it is and why it's needed.

Generated at Mon Feb 12 14:12:43 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.