MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / _renderTemplate

Method _renderTemplate

src/ext/component.js:217–251  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

215 }
216
217 _renderTemplate(source) {
218 // Reuse the existing template rendering infrastructure:
219 // tokenize in "lines" mode, parse as command list, execute to collect string output
220 var ctx = runtime.makeContext(this, null, this, null);
221
222 var buf = [];
223 ctx.meta.__ht_template_result = buf;
224
225 var tokens = tokenizer.tokenize(source, "lines");
226 var parser = createParser(tokens);
227 var commandList;
228 try {
229 commandList = parser.parseElement("commandList");
230 parser.ensureTerminated(commandList);
231 } catch (e) {
232 console.error("hypercomp template parse error:", e.message || e);
233 return "";
234 }
235
236 var resolve, reject;
237 var promise = new Promise(function(res, rej) { resolve = res; reject = rej; });
238
239 commandList.execute(ctx);
240 this.__hs_scopes = ctx.meta.__ht_scopes || null;
241
242 // Sync case - command list completed without going async
243 if (ctx.meta.returned || !ctx.meta.resolve) {
244 return buf.join("");
245 }
246
247 // Async case - stash resolve/reject, return promise
248 ctx.meta.resolve = resolve;
249 ctx.meta.reject = reject;
250 return promise.then(function() { return buf.join(""); });
251 }
252
253 _stampTemplate(html) {
254 if (!this._hypercomp_stamped) {

Callers 2

connectedCallbackMethod · 0.45
_setupReactiveEffectMethod · 0.45

Calls 5

makeContextMethod · 0.45
tokenizeMethod · 0.45
parseElementMethod · 0.45
ensureTerminatedMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected