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

Imported macro cannot see other macros within the same file. #233

Open
albert-kam opened this issue Dec 28, 2019 · 1 comment
Open

Imported macro cannot see other macros within the same file. #233

albert-kam opened this issue Dec 28, 2019 · 1 comment

Comments

@albert-kam
Copy link

Lets say i have a macros.httl that is imported in httl.properties with 2 macros, macroA and macroB.
macros.httl

#macro(macroA(something))
  hello world
#end

#macro(macroB(something))
  <p>
    $!{macroA(someParams)}
  </p>
#end

And in another httl file called test.httl, i can call macroA successfully, meaning the import is working fine. Also, in the same httl file, i'm also calling macroB, and it fails with an error msg saying macroA cannot be found.

test.httl:

<p>$!{macroA(someParams)}</p> <!--ok-->
<p>$!{macroB(someParams)}</p> <!--error-->

Why cannot macroB sees macroA even when they're in the same macros.httl file ?

The error message is something like:

Caused by: java.text.ParseException: No such macro "macroA" or import method macroA(httl.util.Status,java.util.List,java.lang.String).
Occur to offset: 1203, line: 32, column: 57, char: i, in: 

But when i tried copying macroA within macroB, it runs ok, but this means duplicating a lot of macros within another macro.

Am i doing this wrongly ? Please advise.

@albert-kam albert-kam changed the title Imported macro cannot see other macros within the imported file. Imported macro cannot see other macros within the same file. Dec 28, 2019
@albert-kam
Copy link
Author

I also tried splitting a single macro file into multiple macro files, into someting like:

import.macros+=/template/main/macro/form-basic.httl,/template/main/macro/form-input.httl

in hope that form-input.httl can use the macros defined in form-basic.httl, but i still failed.

I also tried #include-ing the form-basic.httl macros into a macro in form-input.httl, and still failed.

I still have to copy paste the macros i need inside the macro that needs to call them.
This works:


#macro(macroA(something))
  hello world
#end

#macro(macroB(something))
  #macro(macroA(something))
    hello world
  #end
  <p>
    $!{macroA(someParams)}
  </p>
#end

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

1 participant