mourner / tinyjam

A radically simple, zero-configuration static site generator in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data from .yml is not included in item.ejs locals

jtleniger opened this issue · comments

I'm trying to define navigation with a .yml file, and then create a nav template that is included in a header template, which is then included in all posts.

From what I can gather, data from top level .yml isn't included in locals for templates defined with item.ejs.

Steps to reproduce:

  1. Create a .yml data file at the top level of the site
  2. Create an index.ejs and output JSON.stringify(locals); note that the .yml is present here
  3. Create a subdirectory with a .md file, and a item.ejs file which outputs JSON.stringify(locals); note that the markdown data is present but none of the data from the top level .yml file is present

It's due to the way root variables are inherited through prototypal inheritance — this is why they don't show up through stringifying. You can still access them through e.g. locals.root.data.foo. Can you try?

D'oh! Didn't realize that was how root worked. Thank you.