Eleventy: Add documentation info for JS Template Literals

Created on 16 Nov 2018  路  8Comments  路  Source: 11ty/eleventy

I've successfully configured eleventy with simple input/output folders and can render things just fine. However, whenever I add a .jslt file it simply fails with "Having trouble rendering template ". Unfortunately, the current documentation gives no indication as to how to properly use template literals. I've tried return literal, module.exports = literal, just having the plain literal in a file, etc. I've even tried something as simple as <h1>Stuff</h1>, but that fails with Having trouble rendering template ./src/test.jstl: '`<h1>Stuff</h1>`'.

I'd greatly appreciate any kind of direction or help here, as I'd love to be able to use template literals.

bug

Most helpful comment

With debug mode on, I'm just getting an error about Could not stringify data / Converting circular structure to JSON (TypeError) on the simplest test.

@zachleat I think we've got a bug

All 8 comments

What do you want to use JS template literals for? As far as I know, Eleventy knows nothing about a JSTL extension. Are you talking about using template literals for template files?

Docs do mention it https://www.11ty.io/docs/languages/jstl/

I hadn't used them yet, but I just did a quick test and also getting the rendering error

With debug mode on, I'm just getting an error about Could not stringify data / Converting circular structure to JSON (TypeError) on the simplest test.

@zachleat I think we've got a bug

Oooooohhhh.

I messed around with the engine a little bit, but comparing to master, looks like Zach has already made some changes to it. Quite possible this may be fixed in next release (I don't know though)

https://github.com/11ty/eleventy/blob/3367e8e5e22ced9989322247d0057e9fd11eacc1/src/Engines/JavaScriptTemplateLiteral.js

See also #263

See also #118

To clarify my previous comments: The problems you鈥檙e having are caused by an active issue, yes. So this is almost certainly a duplicate of #263. Look for the fix in 0.6.0.

Also follow along at #118, which will allow us to do powerful things like named literals, etc etc.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AjitZero picture AjitZero  路  3Comments

michrome picture michrome  路  3Comments

kaloja picture kaloja  路  3Comments

veleek picture veleek  路  3Comments

ndaidong picture ndaidong  路  4Comments