Skip to content

Docs incorrect (or found bug?) about Front Matter in Pug layouts #1465

Open
@Zearin

Description

@Zearin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions