Kel*_*all 13 elixir phoenix-framework
我想在Phoenix Framework中提供静态页面以在Angular Views中使用它.我知道我可以提供常规HTML,但我想摆脱默认值LayoutView
.我可以用一个解决方案来获得一些不"继承"的凤凰视图LayoutView
.可能吗?
Gaz*_*ler 33
您可以通过priv/static
在Plug.Static
选项中包含文件并匹配路径来提供静态文件:
plug Plug.Static,
at: "/", from: :hello_phoenix, gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt my_fine.html)
Run Code Online (Sandbox Code Playgroud)
您还可以使用put_layout/2绕过布局:
conn
|> put_layout(false)
|> render("index.html")
Run Code Online (Sandbox Code Playgroud)
该put_layout/2
函数也可以作为插件调用(由于函数参数).如果您希望它应用于整个控制器,这非常有用:
plug :put_layout, false
Run Code Online (Sandbox Code Playgroud)