예제 #1
0
            public void Create_post_from_file_path_in_unix()
            {
                // Arrange
                var path = @"_posts/2013-02-23-some-nice-article.md";

                // Act
                var post = new Post(path);

                // Assert
                Assert.That(post.Date, Is.EqualTo(new DateTime(2013, 2, 23)));
                Assert.That(post.Slug, Is.EqualTo("some-nice-article"));
                Assert.That(post.Extension, Is.EqualTo("md"));
            }
예제 #2
0
            public void Create_post_from_file_path_with_category()
            {
                // Arrange
                var path = @"_posts\Cat1\2013-02-23-some-nice-article.md";

                // Act
                var post = new Post(path);

                // Assert
                Assert.That(post.Category, Is.EqualTo(new[]
                    {
                        "Cat1"
                    }));
            }
예제 #3
0
 public abstract string RenderPost(string postPath, string templateName, Post model);
예제 #4
0
        public override string RenderPost(string postPath, string templateName, Post model)
        {
            DependencyTracker.Current.Add(postPath, GetFullPath(templateName));
            Template template;
            if (!templatesByName.TryGetValue(templateName, out template))
                throw new TemplateNotFoundException(templateName);

            var hash = CreateHash(new
                {
                    title = model.Title,
                    dependantPath = postPath,
                    path = postPath,
                    post = model
                });
            return template.Render(hash);
        }