new response()
This is an alternative lightweight response class.
On node.js environment, use a jQuery or cheerio object instead.
On browser environment, use a jQuery object for most purpose.
This is a reference implementation to define a common interface for response objects.
Members
-
length :Number
-
This always returns 1. Response object behaves Array-like object which has an item.
Type:
- Number
Example
var app = kawapp(); app.use(some_mw); app.start(function(err, canvas) { $("#canvas").append(canvas[0]); });
Methods
-
append(html) → {response}
-
This appends a block of HTML to the response element.
Parameters:
Name Type Argument Description html
String <repeatable>
HTML to append Returns:
response object for method chaining.- Type
- response
Example
var app = kawapp(); app.use(function(context, canvas, next) { canvas.append("foo"); canvas.append("bar"); });
-
empty() → {response}
-
This flushes the current response element.
Returns:
response object for method chaining.- Type
- response
Example
var app = kawapp(); app.use(function(context, canvas, next) { canvas.empty().append("hi, there!"); });
-
html(html) → {String|response}
-
This replaces or retrieves HTML source of the response element.
Parameters:
Name Type Argument Description html
String <optional>
HTML to replace Returns:
HTML to retrieve, or response element for method chaining.- Type
- String | response
Example
var app = kawapp(); app.use(function(context, canvas, next) { canvas.html("Hello!"); }); app.start(function(err, canvas) { console.log(canvas.html()); // => "Hello!" });