niccolox

niccolox

Solid Filesystem basic syntax help

question about basic Filesystem usage for the Solid hex for Liquid templating. Cross-posting from Github basic Filesystem usage syntax · Issue #96 · edgurgel/solid · GitHub

what am I missing for filesystem usage in a simple Phoenix index action below?

def index(conn, _params) do
    template_path = "/lib/app_web/templates/liquid/"
    file_system = Solid.LocalFileSystem.new(template_path)
    text = Solid.LocalFileSystem.full_path(file_system, "hello")
    render(conn, text)
end
/lib/app_web/templates/liquid/_hello.liquid
hello

gives

    ** (FunctionClauseError) no function clause matching in String.match?/2
        (elixir 1.12.2) lib/string.ex:2259: String.match?(%Solid.LocalFileSystem{pattern: "_%s.liquid", root: "/lib/app_web/templates/liquid/"}, ~r/^[^.\/][a-zA-Z0-9_\/]+$/)
        (solid 0.10.0) lib/solid/file_system.ex:84: Solid.LocalFileSystem.full_path/2

no doubt missing some basic config or awareness around the correct syntax

First Post!

outlog

outlog

maybe you need a Path.absname("foo") eg

template_path = Path.absname("/lib/app_web/templates/liquid/")

also the docs for solid are not coherent on Solid.LocalFileSystem.full_path according to code the argument order is Solid.LocalFileSystem.full_path( "hello", file_system) (yours is opposite) - maybe PR a doc fix..

Where Next?

Popular in Questions Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31525 112
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44608 311
New

We're in Beta

About us Mission Statement