0
我正在学凤凰的Elixir,只是陷入了一个非常愚蠢的问题。我想打电话给一个局部的,从我的索引模板中的呈现方式如下:从elixir的视图中调用渲染部分视图
#index.html.slim
- for element_here <- array_here do
= render MyApp.SharedView, "_game.html.slim", element: element_here
为此,我创建了一个名为查看该shared_view.ex看起来像这样:
defmodule MyApp.SharedView do
use MyApp.Web, :view
def render("game", _assigns), do: "/shared/_game.html.slim"
end
我预期经过共享/ _game.html.slim循环渲染,这是我复制到这里:
.col-md-4.portfolio-item
a href="#"
img.img-responsive alt="" src="http://placehold.it/700x400"/
h3
a href="#" Project Name
p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam viverra euismod odio, gravida pellentesque urna varius vitae.
但没有什么是被渲染。我也没有遇到任何错误。它只是渲染之前和之后的东西。
我不知道我在这里错过了什么。没有路由或控制器操作与“_game”部分相关,因为我认为它不是必需的(我习惯于使用rails并且在那里以这种方式工作)。
尝试'= for'代替o f' - for'。 – Dogbert
nope。一样。 – ntonnelier
你完全相信吗? ' - for'会忽略它内部的html输出,这会导致“它只是在之前和之后呈现这些东西”。 – Dogbert