diff --git a/src/services/schema-form-decorators.provider.spec.js b/src/services/schema-form-decorators.provider.spec.js
index 90ee964df..4892c6876 100644
--- a/src/services/schema-form-decorators.provider.spec.js
+++ b/src/services/schema-form-decorators.provider.spec.js
@@ -50,4 +50,30 @@ describe('schemaFormDecorators', function() {
});
});
});
+
+ describe('#legacy #defineDecoratorWithRawTemplate', function() {
+ it('should enable you to create new decorator directives',function(){
+ module(function(schemaFormDecoratorsProvider){
+ schemaFormDecoratorsProvider.defineDecorator('foobar',{
+ 'foo': {template: '
YES
', replace: true, type: 'template'}
+ },[angular.noop]);
+ });
+
+ inject(function($rootScope,$compile){
+
+ //Since our directive does a replace we need a wrapper to actually check the content.
+ var templateWithWrap = angular.element('
');
+ var template = templateWithWrap.children().eq(0);
+
+ $compile(template)($rootScope);
+ $rootScope.$apply();
+ templateWithWrap.children().length.should.equal(1);
+ templateWithWrap.children().is('foobar').should.be.true;
+ templateWithWrap.children().eq(0).children().length.should.equal(1);
+ templateWithWrap.children().eq(0).children().is('div').should.be.true;
+ templateWithWrap.children().eq(0).children().hasClass('yes').should.be.true;
+ });
+ });
+ });
+
});
diff --git a/src/services/sf-builder.provider.js b/src/services/sf-builder.provider.js
index e864863be..011c70b88 100644
--- a/src/services/sf-builder.provider.js
+++ b/src/services/sf-builder.provider.js
@@ -326,8 +326,8 @@ export default function(sfPathProvider) {
*/
build: function(form, decorator, slots, lookup) {
return build(form, decorator, function(form, field) {
- if (form.type === 'template') {
- return form.template;
+ if (field.type === 'template') {
+ return field.template;
}
return $templateCache.get(field.template);
}, slots, undefined, undefined, lookup);