Open PS-davetemplin opened 4 years ago
I'm sure the file exists, but by default JSLT will only load modules from the classpath. So you have to use the API and give the parser a FileSystemResourceResolver
for it to look for files on disk.
Thanks for the clarification. As a user I would expect the tool to load import references relative to where the referencing file exists first and foremost. I would also hope relative paths work.
In the general case loading things from the file system could open all kinds of security holes, which we'd rather avoid. We could use the file system resolver in the command-line client, I guess. As you say it would make sense. A question is whether users would then be confused when the library behaves differently from the CLI.
I'm sure the file exists, but by default JSLT will only load modules from the classpath. So you have to use the API and give the parser a
FileSystemResourceResolver
for it to look for files on disk.
How to use this API inside my Java Spring boot application. As I have utils.jslt inside my "com.example.demo" folder
@RahulKesharwani353 The API will work the exact same way inside Spring boot as it does outside Spring boot. FileSystemResourceResolver
will load from files on the file system. Tbh, I'm not sure what your question is.
@larsga actually I unable to use import statement inside JSLT expression, and I have no idea how to resolve it. Can you please help to solve this
You need to explain what you're doing. Otherwise nobody can tell what is wrong.
Hey see !
I have made an template.jslt and importing it on my string
and this is my folder structure
when I execute the code, I am getting the same error
There are two problems.
JSLT will try to load your .jslt
file from the classpath, but you haven't placed it on the classpath. You've placed it with the source code. So the .jslt
file is not in your .jar
file.
The .
in the import statement will be interpreted as .
, so you won't be able to find the file way down in the folder structure.
To start with, here's what I would do. Move the file to src/main/resources/template.jslt
. Then change the import statement to import "template.jslt"
. Then try again.
If you want to move the file into subfolders of resources
then you need to use /
to separate the folder names, not .
.
okay cool, Thankyou soo mush, it works.
Hey @larsga
previous solution works ! But I am stucked again
before building it was working . as I dockerized the project, Import Statement fails lo load the file while running the docker container . here is my target folder
Here is docker file :
and here is src folder
Look inside app.jar
(it's just a zip file) to see if utils.jslt
is in the top level. If you then import it as "utils.jslt"
it should work.
I guess it is in top level but still not working
Looks like it's not in the top level, but in BOOT-INF/classes
?
Exception in thread "main" com.schibsted.spt.data.jslt.JsltException: Cannot load resource 'jslt-utils.jslt': not found import "jslt-utils.jslt" as app
let source = .env.source let locale = .env.locale let val = .record
{
}
hey @sahilsh1 refer to this https://github.com/schibsted/jslt/issues/134#issuecomment-1438081800
Got error below. File
utilities.jslt
absolutely, positively, definitely exists.