-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
using include
- java.io.FileNotFoundException: [projectpath]/src (Is a directory)
#79
Comments
You have to specify the absolute path with a leading |
However It would be nice if website=> (clojure.java.io/resource "includes/footer.html")
#<URL file:[projectpath]/templates/includes/footer.html>
website=> (clojure.java.io/resource "/includes/footer.html")
nil
website=> (clojure.java.io/resource "../templates/includes/footer.html")
#<URL file:[projectpath]/templates/includes/footer.html> |
you should just be able to set the resource path as follows: |
|
If (import 'java.io.File)
(selmer.parser/set-resource-path!
(map #(str (File. ^String %))
(.split (System/getProperty "java.class.path")
(System/getProperty "path.separator"))) It's a nasty hack, but for illustration this happens to work: (import 'java.io.File)
(selmer.parser/set-resource-path!
(first (filter #(re-matches #".*/templates$" %)
(map #(str (File. ^String %))
(.split (System/getProperty "java.class.path")
(System/getProperty "path.separator")))))) |
I recommend taking a look at how this is setup in Luminus. If you create a new project using
The (parser/set-resource-path! (clojure.java.io/resource "templates")) You can now setup the templates using the your directory structure:
and you should be able to include using the {% include "/includes/footer.html" %} |
I see what you're saying, and that is a way around it, but it seems odd that file locating for For instance this works without any special setup:
Why not have this behave in the same manner?
I would expect it to yield the same sort of file locating approach in (-> (Thread/currentThread)
(.getContextClassLoader)
(.getResource "includes/footer.html")) |
Sure, I agree that making that consistent would be an improvement. I won't have time to look at it in the near future though. |
Would you be interested in making a pr with a fix? |
I'm also short on time, but good to have this issue open for later if the opportunity comes up, or if anyone else would like to take a shot. |
sounds good |
selmer v0.8.2
General project layout:
Declared in
proect.clj
::resource-paths ["public" "resources" "templates"]
This works:
However when adding
{% include "includes/footer.html" %}
to main.html, this error is thrown:The text was updated successfully, but these errors were encountered: