Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_data.json and ReferenceError during "harp compile" #392

Open
comfycode opened this issue Dec 20, 2014 · 4 comments
Open

_data.json and ReferenceError during "harp compile" #392

comfycode opened this issue Dec 20, 2014 · 4 comments

Comments

@comfycode
Copy link

Here is example that runs well via server and throws ReferenceError during compile.

_data.json

{
    "index": {
        "title": "Home"
    }
}

_layout.ejs

<title><%= title %></title>

Current workaround is to access properties defined in _data.json via locals

<title><%= locals.title %></title>

Pretty inconsistent, so I decided to open this issue. Thanks.

@jdcauley
Copy link

Is this occurring from a _data.jsonin the root?

theopak added a commit to theopak/theopak.com that referenced this issue Mar 26, 2015
@theopak
Copy link

theopak commented Mar 26, 2015

I've been seeing the same issue (harp 0.15.2) when a partial references variables that exist in blog/_data.json, but accessing via locals works.

_layout.ejs:

<%- partial('_partials/_post') %>

_partial/_post.ejs:

<%- locals.title %>

@jdcauley
Copy link

@theopak, just ran into the same thing.

@matbrgz
Copy link

matbrgz commented Sep 21, 2019

Same error here.
harp compile output:

{
  "source": "EJS",
  "dest": "HTML",
  "filename": "/opt/harp/src/_partials/head.ejs",
  "lineno": 3,
  "name": "ReferenceError",
  "message": "/opt/harp/src/_layout.ejs:3\n    1| <!DOCTYPE html>\n    2| <html>\n >> 3|   <%- partial( \"_partials/head\" ) %>\n    4|   <body>\n    5|     <%- partial( \"_partials/github\" ) %>\n    6|     <%- partial( \"_partials/header\" ) %>\n\nsite is not defined",
  "stack": "<head>\n  <meta charset=\"utf-8\">\n  <title><%- page.title %> | <%- site.title %></title>\n\n  <!-- CSS -->\n  <link rel=\"stylesheet\" href=\"http://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700|PT+Sans:400\">\n  <link rel=\"stylesheet\" href=\"<%- site.path %>/css/style.css\">\n</head>\n",
  "path": "/opt/harp/src/_layout.ejs"
}

head.ejs

<head>
  <meta charset="utf-8">
  <title><%- page.title %> | <%- site.title %></title>

  <!-- CSS -->
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700|PT+Sans:400">
  <link rel="stylesheet" href="<%- site.path %>/css/style.css">
</head>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants