Exemplo n.º 1
0
        private void RegisterLocalizedHandlebarsHelpers(IComposerHost host)
        {
            ILocalizationProvider localizationProvider = host.Resolve <ILocalizationProvider>();

            host.RegisterHandlebarsHelper(new FormatValueHelper());
            host.RegisterHandlebarsHelper(new IfIsLocalizedBlockHelper(localizationProvider));
            host.RegisterHandlebarsHelper(new LocalizeHelper(localizationProvider));
            host.RegisterHandlebarsHelper(new LocalizeFormatHelper(localizationProvider));
        }
        public void WHEN_Passing_Helper_Before_ComposerHost_Init_Completed_SHOULD_Throw_InvalidOperationException()
        {
            //Arrange
            Mock <IHandlebarsHelper> helper = CreateHelper(GetRandom.String(32));

            //Act
            var exception = Assert.Throws <InvalidOperationException>(() =>
            {
                _composerHost.RegisterHandlebarsHelper(helper.Object);
            });

            //Assert
            exception.Message.Should().Contain("Host must be initialized", "Because the helpers must not be registered before the HandlebarsEngine is created.");
        }
Exemplo n.º 3
0
 private void RegisterHandlebarsHelpers(IComposerHost host)
 {
     host.RegisterHandlebarsHelper(new IfEqualsBlockHelper());
     host.RegisterHandlebarsHelper(new IfNotEqualsBlockHelper());
     host.RegisterHandlebarsHelper(new IfExistsBlockHelper());
     host.RegisterHandlebarsHelper(new IfGtBlockHelper());
     host.RegisterHandlebarsHelper(new IfGteBlockHelper());
     host.RegisterHandlebarsHelper(new IfLtBlockHelper());
     host.RegisterHandlebarsHelper(new IfLteBlockHelper());
     host.RegisterHandlebarsHelper(new EscapeHelper());
     host.RegisterHandlebarsHelper(new LookupHelper());
 }