简体   繁体   中英

How to print plain content at the end of node using groovy MarkupBuilder?

I'm trying to implement a simple breadcrump in grails. I'm using taglib + Groovy MarkupBuilder. I'm use font-awesome too.

So, my problem is I want to put the text 'PROBLEM' after the icon. My code is:

builder.ul(class: "breadcrumb") {
    li {
        a(href: g.createLink(controller: 'dashboard'), 'PROBLEM') {
            i(class: 'icon-home')

        }
    }
}

The generated html is:

<ul class='breadcrumb'>
    <li>
        <a href='/dashboard/index'>
            PROBLEM 
            <i class='icon-home'></i>
        </a>
    </li>
</ul>

The solution is so simple!

You have to use builder.getMkp().yield('SOLUTION') after tag i

builder.ul(class: "breadcrumb") {
    li {
        a(href: g.createLink(controller: 'dashboard'), 'PROBLEM') {
            i(class: 'icon-home')
            builder.getMkp().yield('SOLUTION')
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM