I am trying to create two templates and use the variables of one .ftl
(freemarker) file in another.
I don't really understand why I should use include
vs import
.
#include
is very much like if you copy-paste the content of the included file into the place of the #include
tag. #import
also processes the target file, but doesn't output anything. Instead, it assigns the set of variables (the namespace) created by the imported template to the variables after the as
keyword. As #macro
-s and #function
-s just create variables, #import
is practical for pulling in a collection of utility macros and functions. Also note that #import
-ing the same file for the second time does nothing (as the namespace is only populated once), while calling #include
twice will process the target file twice.
As for JavaScript, FreeMarker runs on the server side, and the JavaScript runs in the browser. So the browser only ever sees the final output from FreeMarker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With