Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Elixir Phoenix:在模板中指定值的渲染模板_Elixir_Phoenix Framework - Fatal编程技术网

Elixir Phoenix:在模板中指定值的渲染模板

Elixir Phoenix:在模板中指定值的渲染模板,elixir,phoenix-framework,Elixir,Phoenix Framework,我正在努力使我的应用程序干燥和模块化。但是,当我试图将一个组件(小模板)放入另一个模板(较大的模块)中,该组件接收调用/“实例化”时传递的动态值时,我遇到了以下错误: assign @conn not available in eex template. Available assigns: [] 我在模块(大模板)中插入的组件(小模板)如下: 菜单 我使用以下方法将其插入我的模块: <%= render myapp.ComponentView, "menuButton.html",

我正在努力使我的应用程序干燥和模块化。但是,当我试图将一个组件(小模板)放入另一个模板(较大的模块)中,该组件接收调用/“实例化”时传递的动态值时,我遇到了以下错误:

assign @conn not available in eex template. Available assigns: []
我在模块(大模板)中插入的组件(小模板)如下:


菜单
我使用以下方法将其插入我的模块:

<%= render myapp.ComponentView, "menuButton.html", class: nil, id: "menuButtonMenu" %>

我在我的页面中插入了我的模块,使用:

<%= render myapp.ModuleView, "header.html" %>


在保持小型组件/大型模块的逻辑清洁和干燥的同时,使其工作的最佳方法是什么?

正如AbM所说,您需要明确传递您关心的分配,例如:

<%= render myapp.ModuleView, "header.html", conn: @conn %>
<%= render myapp.ModuleView, "header.html", conn: @conn %>
<%= link "a link", to: "/", class: assigns[:class] || "default" %>