Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this library does NOT support global variable access within the imported file #12

Open
nykevinwong opened this issue Aug 21, 2019 · 1 comment

Comments

@nykevinwong
Copy link

nykevinwong commented Aug 21, 2019

when importing a FTL file using import keyword, this freemarker library does not recognize that the global variable, which are already accessible within the host file, shall be accessible within imported file as well.

for example, below host file can access currentObject as global variable, but the same global variable can NOT be accessed within imported file "utilities.ftl".

host.ftl
<#assign metadata = currentObject.attributes.meta! >
<#assign attributes = currentObject.attributes!>

<#import "../../macros/utilities.ftl" as utilities>
<#include "../../components/identity.ftl" >

utilities.ftl
<#assign roles= currentObject.attributes.roles>

Error: >>> ABORTED! <<<

The cause of aborting was:
FreeMarker template error: The following has evaluated to null or missing:
==> currentObject [in template "macros/utilities.ftl" at line 9, column 22]


Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last st
ep of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??


FTL stack trace ("~" means nesting-related):
- Failed at: #assign rolesData = currentObject.att... [in template "macros/utilities.ftl" at line 9, column 1]
- Reached through: #import "../../macros/utilities.ftl" ... [in template "components/identity.ftl" at line 1, column 1]
- Reached through: #include "../../compone... [in template "test/react-tests/__temp__identity-test.ftl" at line 12, column 1]

@int64ago
Copy link
Member

PR welcome, for we don't use this in our work anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants