Custom DSL: Backing objects

  • For defining discrete objects of the domain
@RssDsl
class Entry() : SyndEntryImpl() {

  fun content(content: String) { 
    description = SyndContentImpl().apply { 
      value = content
      type = "text/string"
    }
  }

  fun content(block: HTML.() -> Unit) { 
    description = SyndContentImpl().apply { 
      value = StringWriter()
          .appendHTML(prettyPrint = false)
          .html { 
            apply(block)
          }.toString()
      type = "text/html"
    }
  }
}

Back Home Next