public void CanCompileAndRunLater()
		{
			var service = new HandlebarsService();
			service.Compile("template-name", "Hello {{name}}");

			Assert.Equal("Hello Matt", service.Run("template-name", new { name = "Matt" }));
		}
示例#2
0
        public void CanCompileAndRunLater()
        {
            var service = new HandlebarsService();

            service.Compile("template-name", "Hello {{name}}");

            Assert.Equal("Hello Matt", service.Run("template-name", new { name = "Matt" }));
        }
示例#3
0
        public void SupportsRootLookupThroughPartial()
        {
            var service = new HandlebarsService();

            string template = "Your name is {{>person_name}}";
            var    model    = new { world = "World", person = new { forename = "Matthew", surname = "Abbott" } };

            string partial = "{{@root.person.forename}} {{@root.person.surname}}";

            service.RegisterPartial("person_name", partial);

            service.Compile("hello-world", template);
            string result   = service.Run("hello-world", model);
            string expected = "Your name is Matthew Abbott";

            Assert.Equal(expected, result);
        }
示例#4
0
		public void SupportsRootLookupThroughPartial()
		{
			var service = new HandlebarsService();

			string template = "Your name is {{>person_name}}";
			var model = new { world = "World", person = new { forename = "Matthew", surname = "Abbott" } };

			string partial = "{{@root.person.forename}} {{@root.person.surname}}";
			service.RegisterPartial("person_name", partial);

			service.Compile("hello-world", template);
			string result = service.Run("hello-world", model);
			string expected = "Your name is Matthew Abbott";
			
			Assert.Equal(expected, result);
		}