【发布时间】:2020-04-07 16:55:35
【问题描述】:
我正在我的 rails 应用程序的控制器中生成一个 Mustache 模板。我能够很好地生成html。我的问题是我无法从 assets 文件夹中加载图像。
我尝试使用 ActionController::Base.helpers.image_tag 和 ActionController::Base.helpers.asset_path,然后将其作为变量传递到 Mustache 模板中的图像标记中,作为资产路径的 <img src="{{ asset_path }}" /> 和 image_tag 的输出原样<div> {{ image_tag }} </div>
我知道 image_tag 和 assets_path 正在拾取图像,因为当我输入不正确的路径时,它会输出错误。
有人对如何将此图像链接到 Mustache 模板有任何想法吗?
【问题讨论】:
-
您能分享一下您是如何在控制器中创建模板的吗?