[MGNLDEMO-22] Freemarker Scripts: Should be simplified and best practices should be used Created: 06/May/15  Updated: 01/Jul/15  Resolved: 09/Jun/15

Status: Closed
Project: Magnolia Demo Projects
Component/s: magnolia-travels
Affects Version/s: 0.5
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Christian Ringele Assignee: Espen Jervidalo
Resolution: Obsolete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
supersession
is superseded by MTE-20 Don't store html elements in website ... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

I see in many scripts parts which are either too complicated or do not use scripting best practices.
This should be changes to make the readability and understandability much better.

One example (textImage.ftl):
Original

[#assign headingLevel = "h2"]
[#if content.headingLevel?has_content]
    [#assign headingLevel = content.headingLevel]
[/#if]

[#if content.headline?has_content]
    <${headingLevel}>${content.headline!}</${headingLevel}>
[/#if]

Replacing with (using properly "!"):

[#assign headingLevel = content.headingLevel!"h2"]
[#if content.headline?has_content]
    <${headingLevel}>${content.headline}</${headingLevel}>
[/#if]

Better would be even delegating to the parameters def the default heading level.
Like this more variations could be created using a different default heading level:

[#assign headingLevel = content.headingLevel!def.parameters.defaultHeadingLevel!"h2"]
[#if content.headline?has_content]
    <${headingLevel}>${content.headline}</${headingLevel}>
[/#if]


 Comments   
Comment by Espen Jervidalo [ 09/Jun/15 ]

This has been fixed in linked ticket.

Generated at Mon Feb 12 05:15:31 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.