-
-
Save ef4/c7c2fc91095b6375ef9b92a146a07561 to your computer and use it in GitHub Desktop.
EachChunk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { Component } = Ember; | |
export default class EachChunk extends Component {}; | |
EachChunk.tagName = ''; | |
EachChunk.reopenClass({ | |
positionalParams: ['items', 'chunkSize'] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { Component } = Ember; | |
export default class SimpleElement extends Component {}; | |
SimpleElement.reopenClass({ | |
positionalParams: ['tagName'] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
items: [ | |
'Chris', '@runspired', 'James', 'Wesley', 'Zach', 'Jill', 'Tanya', 'Renee', 'Rosemary', 'Thomas', 'John' | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export function chunk(params/*, hash*/) { | |
let [items, chunkSize] = params; | |
let chunks = []; | |
for (let i = 0; i < items.length; i++) { | |
let chunk = []; | |
chunks.push(chunk); | |
for (let j = 0; j < chunkSize && i < items.length; j++, i++) { | |
chunk.push({ | |
item: items[i], | |
index: i | |
}); | |
} | |
} | |
return chunks; | |
} | |
export default Ember.Helper.helper(chunk); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.2.2", | |
"ember-template-compiler": "3.2.2", | |
"ember-testing": "3.2.2" | |
}, | |
"addons": { | |
"ember-data": "3.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment