Comments (1)
Thank you for a very good question, @dotloadmovie . I am glad you like enduro.js, I hope we can improve it together.
Yea, this can't be currently done easily, but I wish it was because it's a good idea ;-)
I created a sample for you: https://github.com/Gottwik/enduro_samples/tree/master/related_articles
The idea is to load the related articles using a custom handlebars helper. Veeery simple. Basically you just use enduro.api.flat.load('<path-to-your-file>')
to fetch the context.
The template looks like this:
<h1>{{name}}</h1>
<p>{{text}}</p>
<h3>related articles:</h3>
<ul>
{{#related_articles}}
<li>{{name}}</li>
{{/related_articles}}
</ul>
and the helper looks like this:
var Promise = require('bluebird')
enduro.templating_engine.registerHelper('related_articles', function (options) {
// store the actual rendered html
// alternativelly a each helper could be used
var rendered_html = ''
// store the promises to read related articles
var related_article_promises = []
// go throgh all relate articles and load them
for (index in this.related_articles) {
// store the related article
var related_article = this.related_articles[index]
// load the actual content of the article
var related_article_promise = enduro.api.flat.load('/generators/article/' + related_article.related_article_id)
.then((related_article_context) => {
// generate the actual html code
return options.fn(related_article_context)
})
.then((rendered_html_block) => {
// add the html code together with the previous ones
rendered_html += rendered_html_block
})
// add whole thing to a array of promises
related_article_promises.push(related_article_promise)
}
// return whole html block upon reading all related articles
return Promise.all(related_article_promises)
.then(() => {
return rendered_html
})
})
Eeeh, it looks complicated, but it isn't, I promise!
Btw, the circular thing could be solved by a shallow globalizer: http://www.endurojs.com/docs/globalizer#shallow-globalizer
Let me know if this helps you, or if you had any other ideas on how to solve this.
from enduro.
Related Issues (20)
- Enduro 1.4.47 & netlify throw Error: Unexpected argument: _generated HOT 2
- Theme mirror dependency kiskabricks_wedgecss HOT 1
- Managing changes to existing data when changing structure
- Slugs not editable
- Security Vulnerabilities found using `npm audit`
- Cannot open Admin interface on freshly created enduro project HOT 2
- Feature request: Enduro.json as js config file
- Enduro js Deployment Node.js hosting HOT 1
- An in-range update of browser-sync is breaking the build 🚨 HOT 4
- installation errors using - sudo npm install enduro -g HOT 1
- How do you debug Enduro?
- How do I set process.env.PORT in EnduroJS?
- Netlify and Github - How to? Get some errors HOT 1
- Does not work with Node.js 12 (Gulp 3 EOL)
- Checksum error in glyf after node upgrade from v9 to v10
- why does it need visual studio and python version b/w 2.6 and 3.6 for installation ?
- Admin navigation panel sorting
- Enduro js don't create new project. HOT 8
- Is Enduro still actively maintained? HOT 4
- 404 Not Found
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enduro.