sintaxi / harp

Static Web Server/Generator/Bundler
http://harpjs.com
5k stars 346 forks source link

Global value not changed in _layout.ejs after update in partial #616

Open mankewd opened 6 years ago

mankewd commented 6 years ago

I'm trying to dynamically set the page title of the pages in my static site using a recipe suggested by Raymond Camden. (https://www.raymondcamden.com/2015/07/08/using-friendlier-urls-for-a-harpjs-static-site/). I've pared down the example to just the code I want to retrieve the pageTitle based on the file path and the code seems to be working but oddly the pageTitle global is still unset in my _layout.ejs and the rendered page does not contain the pageTitle selected from the list defined in my _data.json array.

I've attached my code, can anyone see a problem with my structure? Or is there some timing issue in the pre-processing phase when Harp is generating the HTML files for the static site? The HarpJS documentation states that globals are available to all elements, layout, partials, etc but it doesn't seem to work in my site. Thanks for taking a look.

_harp.json.txt _layout.ejs.txt _page_parser.ejs.txt _data.json.txt

sintaxi commented 6 years ago

Is there a reason these are .txt files?

mankewd commented 6 years ago

Yes, Github doesn't allow files with ejs or json extensions to be uploaded so I just added a .txt extension to the original file names. Sorry I didn't clarify that when I logged this issue.


From: Brock Whitten notifications@github.com Sent: Sunday, 1 October 2017 8:05 PM To: sintaxi/harp Cc: mankewd; Author Subject: Re: [sintaxi/harp] Global value not changed in _layout.ejs after update in partial (#616)

Is there a reason these are .txt files?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/sintaxi/harp/issues/616#issuecomment-333363376, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AewVkxdHsZ-95z3pLi5iHP0ndJaPJwU3ks5sn1XIgaJpZM4Pp0D3.

misterhtmlcss commented 5 years ago

@sintaxi @mankewd did we get anywhere on this issue?

sintaxi commented 5 years ago

I'll write a test for this.