<p>When using Groovy <code>MarkupBuilder</code>, I have places where I need to output text into the document, or call a function which outputs text into the document. Currently, I'm using the undefined tag <em>"text"</em> to do the output.  Is there a better way to write this code?</p>

<pre><code>li {
  text("${type.getAlias()} blah blah ")
  function1(type.getXYZ())
  if (type instanceof Class1) {
    text(" implements ")
    ft.getList().each { 
      if (it == '') return
      text(it) 
      if (!function2(type, it)) text(", ")
    }
  }
}
</code></pre>

[{'answer_id': 23734, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': "<p>Include a method:</p>\n\n<pre><code>void text(n){\n    builder.yield n\n}\n</code></pre>\n\n<p>Most likely you (I) copied this code from somewhere that had a text method, but you didn't also copy the text method.  Since MarkupBuilder accepts any name for the name of a tag and browsers ignore unknown markup, it just happened to work.</p>\n"}, {'answer_id': 81815, 'author': 'Hank Gay', 'author_id': 4203, 'author_profile': 'https://Stackoverflow.com/users/4203', 'pm_score': 3, 'selected': False, 'text': "<p>Actually, the recommended way now is to use <code>mkp.yield</code>, e.g.,</p>\n\n<pre><code>src.p {\n    mkp.yield 'Some element that has a '\n    strong 'child element'\n    mkp.yield ' which seems pretty basic.'\n}\n</code></pre>\n\n<p>to produce</p>\n\n<pre><code>&lt;p&gt;Some element that has a &lt;strong&gt;child element&lt;/strong&gt; which seems pretty basic.&lt;/p&gt;\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/23169', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']