harp icon indicating copy to clipboard operation
harp copied to clipboard

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

Open mankewd opened this issue 8 years ago • 4 comments

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

mankewd avatar Oct 01 '17 07:10 mankewd

Is there a reason these are .txt files?

sintaxi avatar Oct 01 '17 09:10 sintaxi

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 [email protected] 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.

mankewd avatar Oct 01 '17 09:10 mankewd

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

misterhtmlcss avatar Oct 04 '18 03:10 misterhtmlcss

I'll write a test for this.

sintaxi avatar Oct 04 '18 04:10 sintaxi