TagHelper providers
The way Mvc Controls Toolkit controls TagHelper generate Html is controlled by TagHelpersProviders, that is,
by classes that implement the ITagHelpersProvider
interface (MvcControlsToolkit.Core.TagHelpers namespace).
More specifically each TagHelper performs some general operations and then calls
the function returned by ITagHelpersProvider.GetTagProcessor(string tagName)
, of the current TagHelper where tagName
is the tag name.
If no TagHelpersProvider is explicitely specified somehow the DefaultTagHelpersProvider
class is used (MvcControlsToolkit.Core.TagHelpers.Providers namespace).
This TagHelper renders server controls (ie controls whose templates are in instantiated on the server side), essentailly based on Bootstrap.
All controls of this TagHelpersProvider use View based templates. Thus, the developer may easily
change controls graphic either globally, by providing Views with the same name in the Shared folder, or locally for a specific controller,
by providing Views with the same name in that controller specific folder.
Moreover, all controls give the possibility of specifying a custom template, so the developer may change
templates also on a single control instance basis.
All Views implementing DefaultTagHelpersProvider
templates are here.
In future versions we will implement also various TagHelpersProviders that create client controls ((ie controls whose templates are in instantiated on the client side), based on famous client side frameworks, like Angular2, Knockout.js, Handlebar.js, Aurelia, etc.
How to add further taghelpers
TagHelpersProviders other than the default one must be registred in the Asp.net core DI engine before being used by calling:
services.AddTagHelpersProvider(Type providerType,
ITagHelpersProvider instance=null)
If you specify just the provider type the provider will be created with standard settings otherwise you may provide yourself the instance to be used in the application.
How to specify a TagHelpersProvider
A TagHelpersProvider different from the default one may be installed globally,
when calling AddMvcControlsToolkit,
by passing this method the optional Action
argument:
services.AddMvcControlsToolkit(o =>
o.DefaultProvider= new AnotherTagHelperProvider()
);
A globally installed TagHelpersProvider doesn't need to be registred with AddTagHelpersProvider
.
A different TagHelpersProvider may be specified on a single section of a View,
by enclosing the markup that must use the different TagHelpersProvider
within a use-provider
tag:
<use-provider provider-type="typeof(AnotherTagHelperProvider)" >
...
...
</use-provider>
In future versions when client controls TagHelpersProviders will be implemented,
the use-provider
tag will contain further attributes to specify information about
the client side ViewModel to be used by all client side controls.