Is it possible to support inline templates rather than template url for decorators?
The angular convention when specifying templates in directives/components is to use the template property when supplying inline HTML, and templateUrl when specifying a url.
Schema-form seems to only have the 'template' property, but confusingly, it actually means templateUrl in schema-form world.
I understand that you probably don't want to change the API now, but is there any way of specifying inline HTML, maybe by creating a templateHtml property when defining the decorator?
At the moment you have this:
decoratorsProvider.defineDecorator('myDecorator', {
textarea: {template: base + 'textarea.html', builder: defaults}
}, []);
I would like to do this:
decoratorsProvider.defineDecorator('myDecorator', {
textarea: {templateHtml: '<div class="my-decorator"></div>', builder: defaults}
}, []);
+1. This would be particularly useful when running a webpack build.
+1 would make life a little easier!
The new alphas are built with webpack using the following format:
import actionsTemplate from './bootstrap/actions.html';
var defaults = [sfField, ngModel, ngModelOptions, condition];
decoratorsProvider.defineDecorator('bootstrapDecorator', {
actions: {template: actionsTemplate, builder: defaults},
Combined with 'ngtemplate-loader' it imports everything during the build and adds them to cache.
Alternatively if you look at the calculate add-on in the example folder you will see how to add the template cache into your add-on
.run(function($templateCache) {
// A template to use
$templateCache.put('calculated-fields.html','<calculate sf-field-model model="model" form="form" />');
})
.config([ 'schemaFormDecoratorsProvider', 'sfBuilderProvider',
function(schemaFormDecoratorsProvider, sfBuilderProvider) {
var sfField = sfBuilderProvider.builders.sfField;
var ngModel = sfBuilderProvider.builders.ngModel;
var defaults = [ sfField, ngModel ];
schemaFormDecoratorsProvider.defineAddOn(
'bootstrapDecorator',
'calculate',
'calculated-fields.html',
defaults
);
}
]);
Please re-open if you do not feel the question has been answered sufficiently.