public MissingHelperFeatureFactory(
     HelperDescriptorBase returnHelper     = null,
     BlockHelperDescriptorBase blockHelper = null
     )
 {
     _returnHelper = returnHelper;
     _blockHelper  = blockHelper;
 }
 public MissingHelperFeature(
     HelperDescriptorBase helper,
     BlockHelperDescriptorBase blockHelper
     )
 {
     _helper      = helper;
     _blockHelper = blockHelper;
 }
        /// <summary>
        /// Allows to intercept calls to missing helpers.
        /// <para>For Handlebarsjs docs see: https://handlebarsjs.com/guide/hooks.html#helpermissing</para>
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="helperMissing">Delegate that returns interceptor for <see cref="HandlebarsReturnHelper"/> and <see cref="HandlebarsHelper"/></param>
        /// <param name="blockHelperMissing">Delegate that returns interceptor for <see cref="HandlebarsBlockHelper"/></param>
        /// <returns></returns>
        public static HandlebarsConfiguration RegisterMissingHelperHook(
            this HandlebarsConfiguration configuration,
            HelperDescriptorBase helperMissing           = null,
            BlockHelperDescriptorBase blockHelperMissing = null
            )
        {
            var feature = new MissingHelperFeatureFactory(helperMissing, blockHelperMissing);

            var features = configuration.CompileTimeConfiguration.Features;

            features.Remove(features.OfType <MissingHelperFeatureFactory>().Single());

            features.Add(feature);

            return(configuration);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Registers new <see cref="HelperDescriptorBase"/>
 /// </summary>
 /// <param name="helperObject"></param>
 public static void RegisterHelper(HelperDescriptorBase helperObject)
 {
     Instance.RegisterHelper((HelperDescriptor)helperObject);
 }