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

Add useData: false option to allow custom template engines to opt-out of Data Cascade for templates #3336

Closed
zachleat opened this issue Jun 26, 2024 · 2 comments
Labels
enhancement feature: 🤟 custom template languages eleventyConfig.addExtension API needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.

Comments

@zachleat
Copy link
Member

Example:

const sass = require("sass");

module.exports = function (eleventyConfig) {
	eleventyConfig.addExtension("scss", {
		outputFileExtension: "css",
		useLayouts: false,
		useData: false,

		// `compile` is called once per .scss file in the input directory
		compile: async function (inputContent) {
			let result = sass.compileString(inputContent);
			return async (data) => {
				// Since useData is false, data will be undefined here
				return result.css;
			};
		},
	});
};

Take note also of the existing getData option to add additional data to the data cascade.

https://www.11ty.dev/docs/languages/custom/#getdata-and-getinstancefrominputpath

@zachleat zachleat added enhancement needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. feature: 🤟 custom template languages eleventyConfig.addExtension API labels Jun 26, 2024
@zachleat
Copy link
Member Author

Related #2830

@zachleat
Copy link
Member Author

By default this repo closes enhancement request issues and places them in a queue for folks to upvote. We do this to avoid a large build-up of open issues. We got this idea from the lodash project.

Don’t forget to upvote the first comment with 👍 to register your vote! You can view the current enhancement backlog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature: 🤟 custom template languages eleventyConfig.addExtension API needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.
Projects
None yet
Development

No branches or pull requests

1 participant