TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Enforcing Strict ModelView Separation in Template Engines

3 点作者 tmikew将近 16 年前

1 comment

yannis将近 16 年前
Totally enforcing separation is an almost impossible ideal. You just shifting logic from the controller to the template engine.<p>For example the paper describes how a designer would handle submenus as follows:<p>To handle submenus, have the template iterate (tail-recursively) over the list of submenu items if that menu is active.<p>&#60;a href=$attr.url$&#62;$attr.title$&#60;/a&#62; $if(attr.active)$ $attr.submenu:menuItem()$ $endif$<p>I prefer to send either an array to the View with the menu items and handle the logic in the template or the controller sending the list in a list with classes and id's embedded. I do not like either of them. Has anyone found a solution? I have also tried transclusion a.l.a. wikipedia to ease some of the pain of separation the designer only having to include this {{menu:top}}.<p>Another pet peeve of mine is that Views are more and more becoming programs (i.e ajax, Javascript?), they do not fit in neatly into a model view controller paradigm.<p>Whatever my comments the paper cited above by tmikew is a MUST read.
评论 #765127 未加载