Skip to content

Instantly share code, notes, and snippets.

@clairton
Created June 21, 2018 19:01
Show Gist options
  • Save clairton/fd7b8e0585e313fa91f6571620a327d5 to your computer and use it in GitHub Desktop.
Save clairton/fd7b8e0585e313fa91f6571620a327d5 to your computer and use it in GitHub Desktop.
template company
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
company: {
cnpj: '64.184.287/0001-30'
},
templates: ['64.184.287/0001-30petition-bv2', '64.184.287/0001-30petition-bv3', 'another-value', 'another-petition'],
companyTemplates: Ember.computed('company.cnpj', 'templates.[]', function(){
return this.get('templates').filter(t => {
return t.startsWith(this.get('company.cnpj'))
}).map(t => t.replace(this.get('company.cnpj'), ''));
}),
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<ul>
{{#each companyTemplates as |t|}}
<li>{{t}}</li>
{{/each}}
</ul>
<br>
<br>
{
"version": "0.14.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "2.18.2",
"ember-template-compiler": "2.18.2",
"ember-testing": "2.18.2"
},
"addons": {
"ember-data": "2.18.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment