* Render the contents of a section * @param {method} [_request] a request method to use for loading * @return {string} output a serialized XML Document
(_request)
| 92 | * @return {string} output a serialized XML Document |
| 93 | */ |
| 94 | render(_request) { |
| 95 | var rendering = new defer() |
| 96 | var rendered = rendering.promise |
| 97 | this.output // TODO: better way to return this from hooks? |
| 98 | |
| 99 | this.load(_request) |
| 100 | .then( |
| 101 | function (contents) { |
| 102 | var userAgent = |
| 103 | (typeof navigator !== 'undefined' && navigator.userAgent) || '' |
| 104 | var isIE = userAgent.indexOf('Trident') >= 0 |
| 105 | var Serializer |
| 106 | if (typeof XMLSerializer === 'undefined' || isIE) { |
| 107 | Serializer = XMLDOMSerializer |
| 108 | } else { |
| 109 | Serializer = XMLSerializer |
| 110 | } |
| 111 | var serializer = new Serializer() |
| 112 | this.output = serializer.serializeToString(contents) |
| 113 | return this.output |
| 114 | }.bind(this), |
| 115 | ) |
| 116 | .then( |
| 117 | function () { |
| 118 | return this.hooks.serialize.trigger(this.output, this) |
| 119 | }.bind(this), |
| 120 | ) |
| 121 | .then( |
| 122 | function () { |
| 123 | rendering.resolve(this.output) |
| 124 | }.bind(this), |
| 125 | ) |
| 126 | .catch(function (error) { |
| 127 | rendering.reject(error) |
| 128 | }) |
| 129 | |
| 130 | return rendered |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Find a string in a section |