I have an umbrella app that started out as a json server only (no brunch). Yesterday I added some html routes (with the help of the awesome members of this forum – thankyou!).
I need to add some javascript to some of the templates and have tried to follow the advice given in this post. However, per the console, the js is not being loaded. Below is my setup (controller, template). Regarding the template, I checked the path to the js file:
$ pwd
/Users/carlson/dev/apps/koko/apps/koko_web/priv
$ ls -lh js/asciidoctor.js/asciidoctor.js/dist/asciidoctor.js
-rw-r--r-- 1 carlson staff 1.6M Jun 20 13:26 js/asciidoctor.js/asciidoctor.js/dist/asciidoctor.js
controller
defmodule Koko.Web.PrintController do
use Koko.Web, :controller
alias Koko.Repo
alias Koko.DocManager.Document
plug :put_layout, false
def show(conn, %{"id" => id}) do
document = Repo.get(Document, id)
qs = conn.query_string
case qs do
"text=plain" ->
conn |> render("plain.html", document: document)
"text=adoc" ->
conn |> render("asciidoc.html", document: document)
"text=latex" ->
conn |> render("latex.html", document: document)
_ ->
conn |> render("plain.html", document: document)
end
end
end
template
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<script src="/js/asciidoctor.js/asciidoctor.js/dist/asciidoctor.js"></script>
<div id="asciidoc">
<%= @document.rendered_content %>
</div>
</body>
</html>