Skip to content

Instantly share code, notes, and snippets.

@jelhan
Created September 24, 2018 20:41
Show Gist options
  • Save jelhan/6ea05a2e9c884bd772eefabc91173d08 to your computer and use it in GitHub Desktop.
Save jelhan/6ea05a2e9c884bd772eefabc91173d08 to your computer and use it in GitHub Desktop.
so-52484561/ember-if-lastitem-in-each
import Ember from 'ember';
import { computed } from '@ember/object';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
items: computed(function() {
return ['a', 'b', 'c', 'd'];
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<ul>
{{#each items as |item index|}}
<li>
{{item}}
{{#unless index}}(first){{/unless}}
{{#if (eq index (sub items.length 1))}}(last){{/if}}
</li>
{{/each}}
</ul>
<br>
{
"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",
"ember-math-helpers": "2.7.0",
"ember-truth-helpers": "2.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment