In a simple app I’m building I wanted to define a placeholder text for an input field. The text should contain the value of the name property of the model that is behind the template:
{{input type="text" class="new-artist" placeholder=placeholderText value=newTitle }}
I then went ahead and defined placeholderText on the controller:
placeholderText: function() {
return "New " + this.get('name') + " song";
}.property('name')
That works fine but I was wondering about whether it’s considered good practice to define presentation data on the controller. An alternative solution would be to do this on the view. The two snippets would only have to change very slightly. The view:
placeholderText: function() {
return "New " + this.get('context.name') + " song";
}.property('name')
The template:
{{input type="text" class="new-artist" placeholder=view.placeholderText value=newTitle }}
Is one of the presented solutions better than the other? Or should I use a helper to render the input field? Do I suffer from the “backend-MVC syndrome” to think that presentation concerns so close to “template functionality” have no place on the controller? (If this was not a placeholder property but just the content of an html element I would write the whole thing in the template and be done with it)
Thank you in advance.