Open electerious opened 10 years ago
Thanks for the thorough report.
I think what is happening is title
is unavailable to the _layout.ejs when attempting to render soeme file other than index.{ejs|jade|md}
and that is what is throwing the error. That is why the fallback in globals
fixes the issue.
Do you have any other templates in your project that don't set title
? In this specific circumstance the fallback is a good idea or in your _layout file you can put a fallback there
<%= locals.title || "got your back" %>
hope this helps.
Thanks for the response!
I think what is happening is title is unavailable to the _layout.ejs when attempting to render soeme file other than index.{ejs|jade|md}
There's only a index.ejs
at the moment, so Harp shouldn't try to render other files.
Do you have any other templates in your project that don't set title?
My public/
folder only contains: _layout.ejs
, _data.json
and the index.ejs
I recently started using harp and run into this problem and the cause of it was when I add README.md file in the root directory. Let me know if this solution works for you.
I am running into this issue as well. I was fighting with it for a while. The solution was to delete the node_modules folder. I have harp installed globally, and wasn't using any locally installed packages until now. My website is in the root folder of the project (not /public).
I found that removing the 404.jade
file from my /public
directory also fixed this issue. I did not have any matching objects in my _data.json
file to match "404"
so it seems to be erroring out.
A more detailed explanation is I had several pages in my /public
directory including a _data.json
file and a _layout.ejs
file and the boilerplate 404.jade file. My _layout.ejs
file was using variables in the _data.json
file. In the _data.json
file I had a data object for every page except 404.jade
. So I think harp compile
was crashing when trying to apply my _layout.ejs
to the 404.jade
file.
Relevant files
_data.json:
_layout.ejs:
index.ejs:
The problem
The construction above works when using
harp server
. The content of the site is:However, the same constellation throws an error when compiling the code with
harp compile
:Provisional solution
It works when I define the
title
global in the_harp.json
:The content of
title
will be overwritten by thetitle
in_data.json
. It's the same like shown in this example: https://gist.github.com/kennethormandy/6834709The content of the page is now corrent and also works with
harp compile
.