首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grails平台UI -如何覆盖theme:layoutZone和/或theme:layoutTemplate?

Grails平台UI -如何覆盖theme:layoutZone和/或theme:layoutTemplate?
EN

Stack Overflow用户
提问于 2013-07-01 21:27:21
回答 1查看 262关注 0票数 0

我正在为我需要开发的新Grails web-app测试ui和主题。

我想知道是否有可能在我的应用程序中覆盖主题区域(http://grailsrocks.github.io/grails-platform-ui/guide/creatingThemes.html#themeRequiredZones)。

我知道主题布局和ui集模板(http://grailsrocks.github.io/grails-platform-ui/guide/advanced.html#advancedOverridingThemeLayouts)是可能的。

在我的测试应用程序中,我想重写:

代码语言:javascript
复制
<theme:layoutTemplate name="header"/>
/grails-app/views/_themes/Bootstrap/_header.gsp

代码语言:javascript
复制
<theme:layoutZone name="navigation"/>
/grails-app/views/_themes/Bootstrap/default/_navigation.gsp

这是我的Config.groovy:

代码语言:javascript
复制
compile ":platform-ui:1.0.RC3"
runtime ':bootstrap-theme:1.0.RC3'
grails.plugin.location.'grails-platform-ui-scaffolding' = "../grails-platform-ui-scaffolding"
EN

回答 1

Stack Overflow用户

发布于 2014-06-25 02:39:02

下一版本的platform-ui插件将修复此https://github.com/MerryCoders/grails-platform-ui/pull/7

同时,这里提供了一个自定义TagLib作为变通方法,至少用于layoutTemplate标记。

代码语言:javascript
复制
class OwnThemeTagLib extends org.grails.plugin.platform.ThemeTagLib {

def layoutTemplate = { attrs ->
    def templateView = grailsThemes.getRequestThemeTemplateView(request, attrs.name)

    // Location of app's standard content for theme layout templates
    // /grails-app/views/_themes/<ThemeName>/<templateName>
    def layoutTemplatePath = "/_themes/${templateView.owner}/${attrs.name}"

    // First see if the application provides default content for this template
    if (grailsViewFinder.templateExists(layoutTemplatePath)) {
        if (log.debugEnabled) {
            log.debug "Resolved current request's theme template for [${attrs.name}] to [${layoutTemplatePath}]"
        }
        delegate.out << g.render(template:layoutTemplatePath) 
    } else {
        if (log.debugEnabled) {
            log.debug "Resolved current request's theme template for [${attrs.name}] to [${templateView}]"
        }
        delegate.out << g.render(template:templateView.path, plugin:templateView.plugin)    
    }
}

}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17405618

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档