Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Commit

Permalink
Fix #228
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérémie Bertrand committed Mar 23, 2015
1 parent e485013 commit 78f93fd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Pretzel.Logic/Templating/Context/PageContext.cs
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.IO;

Expand Down Expand Up @@ -80,7 +79,8 @@ public static PageContext FromPage(SiteContext siteContext, Page page, string ou
context.Content = page.Content;
context.Bag = page.Bag;
context.Bag["id"] = page.Id;
context.Bag.Add("url", page.Url);
return context;
}
}
}
}
28 changes: 28 additions & 0 deletions src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs
Expand Up @@ -1830,6 +1830,34 @@ public void The_File_Should_Display_Tags()
}
}

public class Given_Page_Has_Page_Url : BakingEnvironment<LiquidEngine>
{
private const string PageContents = "---\r\n layout: nil \r\n tags: [tag, one, banana] \r\n---\r\n\r\n{{ page.url }}";
private const string ExpectedfileContents = "<p>/2015/02/22/post.html</p>";

public override LiquidEngine Given()
{
var engine = new LiquidEngine();
engine.Initialize();
return engine;
}

public override void When()
{
FileSystem.AddFile(@"C:\website\_posts\2015-02-22-post.md", new MockFileData(PageContents));
var generator = GetSiteContextGenerator(FileSystem);
var context = generator.BuildContext(@"C:\website\", @"D:\Result\_site", false);
Subject.FileSystem = FileSystem;
Subject.Process(context);
}

[Fact]
public void The_File_Should_Display_The_Page_Url()
{
Assert.Equal(ExpectedfileContents, FileSystem.File.ReadAllText(@"D:\Result\_site\2015\02\22\post.html").RemoveWhiteSpace());
}
}

[InlineData("date", @"cat1\cat2\2015\03\09\foobar-baz.html", "cat1,cat2")]
[InlineData("date", @"2015\03\09\foobar-baz.html", "")]
[InlineData("/:dashcategories/:year/:month/:day/:title.html", @"cat1-cat2\2015\03\09\foobar-baz.html", "cat1,cat2")]
Expand Down

0 comments on commit 78f93fd

Please sign in to comment.