diff --git a/src/Pretzel.Logic/Templating/Context/PageContext.cs b/src/Pretzel.Logic/Templating/Context/PageContext.cs index 0203bb5f5..234f64153 100644 --- a/src/Pretzel.Logic/Templating/Context/PageContext.cs +++ b/src/Pretzel.Logic/Templating/Context/PageContext.cs @@ -15,7 +15,7 @@ public PageContext(PageContext context) { Title = context.Title; OutputPath = context.OutputPath; - Bag = context.Bag; + Bag = new Dictionary(context.Bag); Content = context.Content; Site = context.Site; Page = context.Page; diff --git a/src/Pretzel.Logic/Templating/JekyllEngineBase.cs b/src/Pretzel.Logic/Templating/JekyllEngineBase.cs index 5d0d1efc2..599cd4050 100644 --- a/src/Pretzel.Logic/Templating/JekyllEngineBase.cs +++ b/src/Pretzel.Logic/Templating/JekyllEngineBase.cs @@ -122,7 +122,9 @@ private void ProcessFile(string outputDirectory, Page page, Page previous, Page prevLink = link; var path = Path.Combine(outputDirectory, link.ToRelativeFile()); - pageContexts.Add(new PageContext(pageContext) { Paginator = newPaginator, OutputPath = path }); + var context = new PageContext(pageContext) { Paginator = newPaginator, OutputPath = path }; + context.Bag["url"] = link; + pageContexts.Add(context); } } diff --git a/src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs b/src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs index 74b7637cc..8efcf52a0 100644 --- a/src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs +++ b/src/Pretzel.Tests/Templating/Jekyll/LiquidEngineTests.cs @@ -237,10 +237,10 @@ public void No_Pages_Should_Be_Generated() public class When_Paginate_With_Default_Pagelink : BakingEnvironment { - private const string TemplateContents = "{{ page.title }}{{ content }}"; + private const string TemplateContents = "{{ page.title }}{{ content }}"; private const string PostContents = "---\r\n layout: default \r\n title: 'Post'\r\n---\r\n\r\n## Hello World!"; private const string IndexContents = "---\r\n layout: default \r\n paginate: 1 \r\n title: 'A different title'\r\n---\r\n\r\n

Hello World!

{{ paginator.previous_page }} / {{ paginator.page }} / {{ paginator.next_page }}

"; - private const string ExpectedfileContents = "A different title

Hello World!

{0} / {1} / {2}

"; + private const string ExpectedfileContents = "A different title

Hello World!

{0} / {1} / {2}

"; public override LiquidEngine Given() { @@ -269,7 +269,7 @@ public void Four_Pages_Should_Be_Generated() for (var i = 2; i <= 5; i++) { var fileName = String.Format(@"C:\website\_site\page\{0}\index.html", i); - var expectedContents = string.Format(ExpectedfileContents, i - 1, i, i + 1); + var expectedContents = string.Format(ExpectedfileContents, i - 1, i, i + 1, "/page/" + i + "/index.html"); Assert.Equal(expectedContents, FileSystem.File.ReadAllText(fileName).RemoveWhiteSpace()); } } @@ -283,7 +283,7 @@ public void Page1_Is_Not_Generated() [Fact] public void But_Index_Is_Generated() { - var expectedContents = string.Format(ExpectedfileContents, 0, 1, 2); + var expectedContents = string.Format(ExpectedfileContents, 0, 1, 2, "/index.html"); Assert.Equal(expectedContents, FileSystem.File.ReadAllText(@"C:\website\_site\index.html").RemoveWhiteSpace()); } }