我在app.html.eex
中有默认web/templates/layout/
,它适用于我的所有模板*.html.eex
。我将app.html.eex
文件复制到app.rss.eex
,我将内容更改为常用RSS代码,仅在我的*.rss.eex
模板中使用特定代码,但它仅将*.rss.eex
重新定义代码而不使用布局。
我试图放入管道plug :put_layout, {Exampleapp.LayoutView, :app}
,但它没有用。当然,我将接受配置为使用带plug :accepts, ["html", "rss"]
的RSS,以便它可以呈现*.rss.eex
模板。
¿可以使用其他格式的布局吗?
¿如何正确使用app.rss.eex
布局?
答案 0 :(得分:2)
您还需要为新格式启用布局。您可以在:put_layout
之前添加:put_layout_formats
插件:
plug :put_layout_formats, ["html", "rss"]
plug :put_layout, ...
答案 1 :(得分:0)
选项1
render(conn, “index.html”, layout: {MyApp.LayoutView, “admin.html”})
选项2
conn
|> put_layout({AdminView, "admin.html"})
|> render :index