| 122 | export function template(f) { |
| 123 | let constructor = this; |
| 124 | let result = function($, it1) { |
| 125 | let self = (this) ? this : Object.create(constructor.prototype); |
| 126 | let it = f.call(self, $, it1); |
| 127 | if (it1) { |
| 128 | let contents = null; |
| 129 | if ("contents" in it) |
| 130 | contents = it.contents; |
| 131 | for (let i in it1) { |
| 132 | if (contents && (i == "contents")) |
| 133 | contents = contents.concat(it1.contents); |
| 134 | else |
| 135 | it[i] = it1[i]; |
| 136 | } |
| 137 | if (contents) |
| 138 | it.contents = contents; |
| 139 | } |
| 140 | return constructor.call(self, $, it); |
| 141 | } |
| 142 | result.prototype = this.prototype; |
| 143 | result.template = template; |
| 144 | return result; |