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

97 Views Asked by At

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>
1

There are 1 best solutions below

0
ricardogobbo On

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')
        }
    }
}