Docs incorrect (or found bug?) about Front Matter in Pug layouts
Nobody has claimed this yet.
- Dominant language
- Nunjucks
- Stars
- 547
- Forks
- 726
- Avg merge
- 2h 23m
- Merged PRs (30d)
- 3
Description
Relevant Docs
The docs for Layouts say:
Layouts can contain their own front matter data!
The problem
I’m using Pug as my template language of choice, and I just tried to add some Front Matter to a layout for the first time. Pug sees the front matter code and chokes when attempting to parse it.
Error output
[11ty] Original error stack trace: Error: _src/_layouts/default.pug:2:1
[11ty] 1| ---js
[11ty] > 2| {
[11ty] -------^
[11ty] 3| cssListAppend: null
[11ty] 4| }
[11ty] 5| ---
[11ty]
[11ty] unexpected text "{
[11ty] "
[11ty] at makeError (/Users/amrogers/Projects/uof-11ty/node_modules/pug-error/index.js:34:13)
[11ty] at Lexer.error (/Users/amrogers/Projects/uof-11ty/node_modules/pug-lexer/index.js:62:15)
[11ty] at Lexer.fail (/Users/amrogers/Projects/uof-11ty/node_modules/pug-lexer/index.js:1629:10)
[11ty] at Lexer.advance (/Users/amrogers/Projects/uof-11ty/node_modules/pug-lexer/index.js:1694:12)
[11ty] at Lexer.callLexerFunction (/Users/amrogers/Projects/uof-11ty/node_modules/pug-lexer/index.js:1647:23)
[11ty] at Lexer.getTokens (/Users/amrogers/Projects/uof-11ty/node_modules/pug-lexer/index.js:1706:12)
[11ty] at lex (/Users/amrogers/Projects/uof-11ty/node_modules/pug-lexer/index.js:12:42)
[11ty] at Object.lex (/Users/amrogers/Projects/uof-11ty/node_modules/pug/lib/index.js:104:9)
[11ty] at Function.loadString [as string] (/Users/amrogers/Projects/uof-11ty/node_modules/pug-load/index.js:53:24)
[11ty] at /Users/amrogers/Projects/uof-11ty/node_modules/pug-load/index.js:37:27
[11ty] Copied 27 files / Wrote 0 files in 4.61 seconds (v1.0.2)
My speculation
Since each parser only knows its own language (but not front matter), my guess is that Eleventy is sending the entire file contents to the Pug parser, when it should be pre-processing the front matter first and sending only Pug code to the Pug parser.
Eleventy Version
- Eleventy version: 1.0.2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Layouts documentation section linked in the issue and reproduce the example using a Pug layout on Eleventy 1.0.2. Check whether front matter is handled before Pug parses the layout, then determine whether the documentation or behavior is incorrect. Done means the documented Pug workflow matches the observed behavior, with a regression test or corrected documentation as appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pug
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100