我可以更改主要使用 CSS 的脚手架页面的外观/感觉吗?

发布于 2024-08-13 08:48:09 字数 697 浏览 4 评论 0原文

我正在使用一个 Web 框架(Grails,类似于 Rails),它能够通过脚手架自动生成大量代码。因此,我的所有 CRUD 页面当前都是自动生成的,而且每当我想要进一步自定义这些页面的内容时,我什至能够注入额外的 HTML 代码。

我可以控制脚手架模板,因此可以将任何生成的字段包装在其自己的 DIV 中,或者在需要时应用样式,所有这些都通过脚手架进行。

因此,如果我有一个带有名称和密码字段的对象,我可以让我的脚手架为“显示”页面生成类似的内容。

<div id="prop.name">Name</div><div id="prop.name.value">John</div>
<div id="prop.password">Password</div><div id="prop.password.value">***</div>

我们即将开始在脚手架页面上进行更真实的设计,我想知道让设计师提出一个基本布局(页眉、页脚、菜单等)是否有意义,但对于实际的我的表单和显示页面的布局,让我的所有 DIV 都有设计师风格。这样,我可以继续通过脚手架创建页面,使我可以轻松添加字段等,但实际上无需编写太多自定义 UI 代码。

显然,可能有一些地方我必须根据设计调整我的脚手架,但目标是重用我的脚手架模板并设计它们的样式。

这种方法有什么想法/问题吗?

I am using a web framework (Grails, similar to Rails) that has abilities to auto-generate a lot of code through scaffolding. As a result, all of my CRUD pages are currently automatically generated, and I even have ability to inject additional HTML code whenever I want to to further customize the content of those pages.

I can control the scaffolding templates and so can wrap any generated fields in its own DIV, or apply styles whenever needed, all through scaffolding.

So if I have an object with name and password fields, I can have my scaffolding generate something like this for "show" page.

<div id="prop.name">Name</div><div id="prop.name.value">John</div>
<div id="prop.password">Password</div><div id="prop.password.value">***</div>

We are about to embark on putting a more real design onto the scaffolded pages, and I am wondering whether it would make sense to just have the designers come up with a basic layout (header, footer, menu, etc), but for the actual layout of my forms and display pages, have the designer style all my DIVs. This way, I can continue to create my pages through scaffolding, allowing me to easily add fields, etc, but without really having to code too much custom UI.

Obviously, there might be a few places where I'd have to adjust my scaffolding to the designs, but the goal is to reuse my scaffolding templates and style them.

Any thoughts / problems with this approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无所谓啦 2024-08-20 08:48:09

我不了解 Grails,但 Rails 生成器输出的 HTML 很糟糕。我永远不会在生产应用程序中使用脚手架代码。尽管它可能很糟糕,但它对于它的预期用途很有用,即快速视觉确认您的 CRUD 操作是否按预期工作。

当然,您可以完全疯狂地使用 CSS 重新设计脚手架视图,您只受您的能力和浏览器实现的 CSS 数量的限制。 (不管你相信与否,Internet Explorer 8 是唯一完全实现 CSS 2.1 的浏览器!)

我建议为每个项目编写视图编码,因为脚手架代码不太可能完美适合问题域。当然,模式会在项目中出现,但这并不意味着使用未触及的脚手架代码很酷!

ps 标签和属性名称应该是小写的! :)

I don't know about Grails but the Rails generators output horrible HTML. I would never use scaffolding code in a production application. As horrible as it might be, it's useful for what it is intended for, i.e. quick visual confirmation that your CRUD actions are working as intended.

You can of course completely go mad restyling the scaffold views with CSS, you're only limited by your chops and how much of the CSS your browser implements. (Believe it or not Internet Explorer 8 is the only browser to fully implement CSS 2.1!)

I recommend coding views for each project as it is unlikely that the scaffold code is going to be a perfect fit for the problem domain. Of course patterns are going to emerge across projects, but that doesn't mean it's cool to roll with untouched scaffold code!

p.s. Tag and attribute names are supposed to be lowercase! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文