Reputation: 459
I have a set 4 template files, all with the .rythm
extension, and all living in the same directory. Let's call them "Main.rythm", "Child1.rythm", "Child2.rythm", and "Helper.rythm". Additionally, I also set the home.template.dir
to this directory before rendering Main.
In the Helper template, I just have a bunch of @def
s that do some basic common formatting so that I don't have to call back to a my java class or clutter up the actual template with logic that doesn't need to be there.
Main looks something like this:
@args {
String aString,
MyClass bunchOfData,
String anotherString
@//...
}
@import("Helper")
There's some formatting here, using @aString
There's some formatting using an @def in Helper, like @foo(anotherString)
@Child1(bunchOfData)
@Child2(bunchOfData)
And Child1 and Child2 are similar to each other and look something like this:
@args MyClass bunchOfData
@import("Helper")
@{
//Some preformatting stuff here
}
Make a lot of method calls on @bunchOfData, some of which will also use an @def or two in Helper
My problem is that I'm getting an error in Child1 on the @import("Helper")
line:
Exception in thread "main" org.rythmengine.exception.CompileException: Syntax error on token "import", delete this token
Template: /path/to/templates/Child1.rythm
I've tried commenting out the @import
, but then I can't really call those @def
s, and get errors from Rythm that "Helper cannot be resolved" when I use @Helper.foo(bunchOfData.getSomething())
.
What is it that I need to do in order to get access to these @def
s in Helper from Child1 and Child2?
Upvotes: 0
Views: 67
Reputation: 459
You shouldn't be using @import
, you should be using @include
instead. @import
is just like the import
directive in java, adding a package for this template to refer to. @include
is for adding additional templates that you can refer to throughout this template.
Upvotes: 1