Issue importing a custom module

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue importing a custom module

Hugo <Nabble>
I created a file called lib/Jtp.luan with just one line of code:
version = "01"
Then I went to another file (in a different folder) and tried:
import "java:lib/Jtp.luan"

%><%=Jtp.version%><%
This doesn't work. Why?
Reply | Threaded
Open this post in threaded view
|

Re: Issue importing a custom module

fschmidt
Administrator
By default Package.path is set to just use what is in the website directory.  This is consistent with the reactionary server.  I think this is okay if the documentation tells people to use a directory structure like what the reactionary server expects.  You can add to the path like this:


at the end of server.luan:

import "Package"
Package.path = Package.path .. ";java:jeans/?.luan"

to import:

import "lib/Jtp"


or more generally:

at the end of server.luan:

import "Package"
Package.path = Package.path .. ";?.luan"

to import:

import "java:jeans/lib/Jtp"
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Issue importing a custom module

Hugo <Nabble>
This explains the issue, thanks.
I am closing this thread.