项目设置:
服务器:Rails
有一个页面只使用了Ember的一个组件(没有加载路由控制器模型的全栈),由于某种原因,带有该组件模板的脚本标签没有在页面上呈现,仅在测试中。
如果手动测试,组件在页面上运行良好,没有显示错误或警告。如果类型与“text/x-handlebar”不同,它将被呈现。其他Ember页面没有这样的问题。
示例标记:
_form. html.ham l
=render 'ember/templates/components/foo_bar'
.row
.span12
<form markup>
恩伯/模板/组件/foo_bar. html.ham l
%script{type: 'text/x-handlebars', data:{'template-name' => 'components/foo-bar'}}
.input-append
<template markup>
如何在页面上呈现此模板?
只是一个变通方法而不是解决方案,但对我有用:
Haml替换为handelbar(. hbs)模板
模板移动到“模板”文件夹
“模板”文件夹添加到application.js清单
Ember-rails做剩下的-编译
只需添加“js: true”
it 'tests the script on presence', js: true do
. . .
end