2

I once read this, because I wanted to see if handlebars is the right view engine for me or rather something else.

A thing that I wonder since then is the following, why is it considered bad, if a view engine

encourages logic in templates?

5
  • 2
    sth is not a word. Nov 14 '14 at 20:42
  • It is a fairly well know abbreviation. As far as I know.
    – Knerd
    Nov 14 '14 at 20:47
  • 4
    I assumed it was short for 'Sith' Nov 14 '14 at 20:57
  • Really? I am really used to abbreviations in my live, like sth. for something. Or btw. for by the way etc. for et cetera :)
    – Knerd
    Nov 14 '14 at 21:00
  • 3
    Use the Queen's English when writings posts on the SE network. This isn't Twitter. Nov 15 '14 at 1:01
5

Separation of concerns.

The concern of templates is visual display of information. Business logic doesn't play any part in that.

User interfaces can contain short loops that iterate over lists. It can also contain validation logic and things like AJAX that improve interactivity. Beyond that, it's generally all server-side, unless the application is self-contained.

0

Business logic doesn't belong in the view. The view should just iterate over your list of objects and output them and provide controls for facilitating change.

1
  • Well, what is, just as an example, with authentication logic?
    – Knerd
    Jan 15 '15 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.