Comments (5)
Hey!
Have you taken a look the bake extra pages section? I think that should work for your use case.
Please let me know if you could apply this to your project.
from grunt-bake.
Hi - Thanks a lot for your reply.
I could potentially apply that. The thing is, the JSON I am using is structured according to "sections", and not as an array. My understanding is that the _foreach statement in bake extra pages goes through items in an array, not through "sections". So I would require the same feature as in bake extra pages, but with the ability to go through "sections" instead of items in an array (e.g. a "mix" of _foreach and _section statement features).
Just to give you some background : I am using grunt-frontmatter to extract frontmatter from a list of markdown files, and it generates that JSON file with filenames as "sections" (so I have little control over how it is structured) :
{
"filename1": {
"language": "fr",
"name": "name1",
"description": "description1"
},
"filename2": {
"language": "fr",
"name": "name2",
"description": "description2"
},
...
}
What do you think ? Thanks a lot in advance !
from grunt-bake.
If the data you have is not matching the requirements grunt-bake
has, you can transform the data by using a function for options.content
:
options: {
content: function() {
var file = './data/content.json';
var content = grunt.file.readJSON(file);
return _.values(content); // e.g. http://underscorejs.org/#values
}
},
You could also do some sorting and mixin the keys (filename1
, filename2
, ...) as a property so they become available in the templates:
return _.chain(content)
.mapObject(function (section, filename) {
return _.extend({}, section, {
filename: filename
});
})
.values()
.sortBy('name')
.value();
from grunt-bake.
Thanks a lot ! I will look into your suggestions. Alternatively I will input my data directly in the required format for grunt-bake
/ bake extra pages.
from grunt-bake.
Hope you found a suitable solution. I will close this issue, since it is not a feature or bug. But I will create one feature issue for supporting iteration over objects in _foreach
from grunt-bake.
Related Issues (20)
- Version for gulp HOT 1
- When in '_section', use properties outside this '_section' HOT 11
- Evaluate content inside of _section HOT 1
- Add variable for linking to originating file when using _bake-attribute HOT 2
- Integration of default transforms HOT 1
- Pass arrays/objects as inline attributes HOT 9
- Can't access properties in _section HOT 1
- bake-escape feature request HOT 20
- JSON file or CSV convert to multiple HTML files HOT 9
- Simple bake test HOT 1
- foreach loop to build multiple files per object HOT 1
- Unset variables are rendered as "undefined" HOT 3
- Placeholder Default HOT 5
- Assign/use variable in same file HOT 1
- Builtin placeholders HOT 2
- How to convert a folder with bake ? HOT 2
- Generate Bake with grunt.config.get HOT 2
- Iteration over objects in _foreach HOT 6
- Can I read from package.json? HOT 2
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 grunt-bake.