Is it a bad practice to use html tags in Model (MVC)?

It is well known that creating variables or putting logic in the View (MVC) is a very bad practice, so my question is quite the opposite, is it a bad practice to create view components (use html tags) in the Model (MVC) ?

Sometimes, a simple loop is not enough in my View and I need to use recursive function in order to convert my node of “tree” to a string object in my Model, then print the string object in the View. So I admit, I generate html tags in my Model even if there’s always a way to convert a tree to list then send a “loop-able” list to the View.

But there’s a second reason for me to create html components in my Model, because it is easier when I change framework, I do not need to convert my View to another format (.jsp , .xhtml for Facelets, …).

=> Is it a really bad practice to use html tags in the Model (MVC) ? Why ? Thanks


Source: html

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.