Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Porting switch plug-in from v2 to v3?

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
Darker
Smarty n00b


Joined: 19 Apr 2012
Posts: 3

PostPosted: Mon Jan 12, 2015 6:52 am    Post subject: Porting switch plug-in from v2 to v3? Reply with quote

This switch plugin is really awesome. But it throws errors under V3 because it was designed for V2.

Does anybody know how hard would it be to port it to the newer version?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1531

PostPosted: Mon Jan 12, 2015 3:36 pm    Post subject: Reply with quote

The topic you linked claims compatibility with Smarty3.
Though, I fail to see the "awesomeness" of such plugin. If you need such a convoluted logic, you probably did not gave your templates a thought.
The view logic must be very simple.
Back to top
View user's profile Send private message
Darker
Smarty n00b


Joined: 19 Apr 2012
Posts: 3

PostPosted: Mon Jan 12, 2015 3:59 pm    Post subject: Reply with quote

Switch is much simpler to read than bunch of else/if commands. This is why switch exists in programming languages as you probably fail to see.

And you often happen to have several states certain part of site may display.

Anyway I just noticed the version 3 should be here but the download is missing...
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1531

PostPosted: Tue Jan 13, 2015 3:27 am    Post subject: Reply with quote

Template is not a program.
If you need complex programming in template, you're diminishing the very idea of MVC principle.
Template should not include business logic.
Back to top
View user's profile Send private message
Darker
Smarty n00b


Joined: 19 Apr 2012
Posts: 3

PostPosted: Tue Jan 13, 2015 7:18 am    Post subject: Reply with quote

Once again, seems you take a long time to understand this:

switch was invented to replace long unreadable chains of if/else statements. This is no complicated program logic. This is about making code more readable. If you have problem with {switch}, you should also dislike {if}, not talking about {section} and {foreach} which are both more complex than {switch}.

Beside from that for the given task I see no other solution - and neither do you, otherwise you'd mention it. You probably feel smart chaining {if}s instead.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5067
Location: Hamburg / Germany

PostPosted: Fri Jan 16, 2015 7:34 pm    Post subject: Reply with quote

For example see See https://github.com/pynej/Smarty-Switch-Statement
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP