-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Is it possible to pre-process a Javascript template and return the content to a Liquid/Nunjucks one? #1160
Comments
I believe this is a duplicate of enhancement request #148—do you agree? |
A short-term thing you can do is put the stuff into a collection and reference that. |
@zachleat possibly? I was poking around on #272 and am in this case experimenting with using 11ty to run some simple build steps to generate CSS, JS, etc. While the flexibility of rendering one template type within another would certainly be awesome, what I'm hoping to do currently is handle the processing of output within a template, and if it's small enough, inline it. My quick fix so far is to have these sorts of things handled by a universal shortcode that could either run in a nunjucks/liquid template and inline the result or run in a JS template and render the result with the output permalink being I'll look at the documentation again, how would a collection help order the processing steps? |
I stumbled over this by trying to have an SSR components' html included in otherwise plain old html. I tried to include an |
Coming back to this: filters and shortcodes ended up being the best solve for me with regard to "computing a thing"/"injecting results in template". With a configured shortcode that either takes additional parameters or not, I can either use it within a template to return the results of the job, or create a template that just contains the shortcode to generate a file containing the results of the job. In addition, if I dont need to access the shortcode project-wide, then I can cut overhead by having a JS template run what would have otherwise come from the shortcode, or import the shortcode function from a config file. Lots of choices. Thanks for all the responses on this, going to close now. |
EDIT 05/11/2020: Simplified my original question to avoid confusion about what I'm asking.
If I have multiple javascript templates (.11ty.js) that do different things and then return some content, ie
and want to include their results it into a liquid/nunjucks template, I'm thinking I could just do a:
but that only inserts the raw content of the js template rather than what it renders. Is it possible to have Eleventy process the JS template first and then have the results included in a different template? Or is this something better handled by a shortcode?
The text was updated successfully, but these errors were encountered: