MCPcopy
hub / github.com/pugjs/pug / applyYield

Function applyYield

packages/pug-linker/index.js:162–189  ·  view source on GitHub ↗
(ast, block)

Source from the content-addressed store, hash-verified

160}
161
162function applyYield(ast, block) {
163 if (!block || !block.nodes.length) return ast;
164 var replaced = false;
165 ast = walk(ast, null, function(node, replace) {
166 if (node.type === 'YieldBlock') {
167 replaced = true;
168 node.type = 'Block';
169 node.nodes = [block];
170 }
171 });
172 function defaultYieldLocation(node) {
173 var res = node;
174 for (var i = 0; i < node.nodes.length; i++) {
175 if (node.nodes[i].textOnly) continue;
176 if (node.nodes[i].type === 'Block') {
177 res = defaultYieldLocation(node.nodes[i]);
178 } else if (node.nodes[i].block && node.nodes[i].block.nodes.length) {
179 res = defaultYieldLocation(node.nodes[i].block);
180 }
181 }
182 return res;
183 }
184 if (!replaced) {
185 // todo: probably should deprecate this with a warning
186 defaultYieldLocation(ast).nodes.push(block);
187 }
188 return ast;
189}
190
191function checkExtendPosition(ast, hasExtends) {
192 var legitExtendsReached = false;

Callers 1

applyIncludesFunction · 0.85

Calls 1

defaultYieldLocationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…