Hello everyone,
I’m in the process of building a Smart View and I’m wondering if there is a list of available Ember helpers that I can use. For instance, I can see in the demo samples that moment-format
is available for formatting dates. Are there other helpers available? Specifically, I’m looking for a currency formatter, but a comprehensive list would be even better.
Alternatively, I cannot figure out how to integrate my own helpers…
Merci d’avance,
Arthur — from Homeloop
1 Like
Hi
@arthur.derouge welcome to our community, unfortunately we don’t have a list yet.
But you can do something like that to create your own helper.
In your component file
import Component from '@ember/component';
import SmartViewMixin from 'client/mixins/smart-view-mixin';
import { getOwner } from '@ember/application';
import Helper from '@ember/component/helper';
export default Component.extend(SmartViewMixin, {
init(...args) {
this._super(...args);
const container = getOwner(this);
container.register('helper:substring', Helper.extend({
compute(args) {
let [string, start, end] = args;
return string.substring(start, end);
}
}));
},
});
In your template file
<div class="c-empty">
<div class="c-clr-1-4">
<span class="c-empty__illustration l-dmb fa fa-{{collection.iconOrDefault}} fa-5x"></span>
<h1 class="l-hmb">
{{word-pluralize collection.displayName}}
({{recordsCount}})
{{substring "testingsubstring" 0 5}}
</h1>
<p>
You can now implement your Smart View.
</p>
</div>
</div>
2 Likes
Thanks a lot @Arnaud_Moncel. It works perfectly!