Following the
docs I tried using this code block:
def products = Product.list()
withFormat {
html productList: products
json { render products as JSON }
}A call to /product/list?format=json returns the JSON for the products but a call to /product/list?format=html renders the product/list view but the products are not passed in
I found this works though:
withFormat {
html { [ products: products ] }
...
}or
withFormat {
html { new ModelAndView('list', [ products: products]) }
...
}Am I missing something or do the docs need updating?