为 Grails 脚手架禁用 sitemesh?

发布于 2024-11-30 04:32:26 字数 58 浏览 9 评论 0原文

如何禁用支持脚手架的控制器的模板和 sitemesh?我想在这里显示完整的脚手架,我的主模板与此有关。

How do I disable templating and sitemesh for scaffold-enabled controllers? I want to display the full scaffold here, and my main template is screwing with this.

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

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

发布评论

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

评论(3

海风掠过北极光 2024-12-07 04:32:26

我认为您想重命名脚手架视图中使用的布局名称。完成后,

grails install-templates

您就拥有了生成的脚手架页面的模板(当您执行grailsgenerate-all*时,您可能已经使用过该模板)。在新文件夹 src/templates/scaffolding/*.gsp 中,将布局名称更改为类似于 generatedMain 的名称。我想您知道,但为了确定:

<meta name="layout" content="generatedMain" />

现在恢复原始的 main.gsp 并将其重命名为 generateMain.gsp。然后使用 grailsgenerate-all * 重新生成脚手架视图。

至少,这是我在几个项目中所做的方式;-)

I think you want to rename the layout name used from the scaffolded views. After you did

grails install-templates

you have the template of the generated scaffolded pages (which you might have used, when you did grails generate-all *). In the new folder src/templates/scaffolding/*.gsp change the layout name to something like generatedMain. I guess you know, but just to be sure:

<meta name="layout" content="generatedMain" />

Now restore the orginal main.gsp and rename it to generatedMain.gsp. Then regenerate your scaffolded views using grails generate-all *.

At least, this is the way I did it in a couple of projects ;-)

绾颜 2024-12-07 04:32:26

更改非脚手架视图以使用“foo”布局,方法是在每个(非脚手架)GSP 的 中明确声明它,或者将以下内容添加到 Config .groovy

grails.sitemesh.default.layout = 'foo'

此时,只有脚手架页面将使用“主”布局,您可以通过将其更改为以下内容来有效地使其成为“空”布局:

<html>
  <head>
    <g:layoutHead/>
  </head>
  <body>
    <g:layoutBody/>
  </body>
</html>

Change your non-scaffolded views to use a 'foo' layout, either by stating it explicitly in the <head> of each (non-scaffolded) GSP or by adding the following to Config.groovy

grails.sitemesh.default.layout = 'foo'

At this point, only the scaffolded pages will be using the 'main' layout and you can effectively make this an "empty" layout by changing it to something like:

<html>
  <head>
    <g:layoutHead/>
  </head>
  <body>
    <g:layoutBody/>
  </body>
</html>
下壹個目標 2024-12-07 04:32:26

不要使用 main.gsp 作为主布局。相反,使用 yourlayout.gsp,在 GSP 中手动设置它,然后使用的 sitemesh 将成为默认值,这就是脚手架所需的。

Don't use main.gsp as your main layout. Rather, use yourlayout.gsp, manually set it in your GSPs, and then the sitemesh used will be the default, which is what you need for the scaffold.

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