Given a tag and a vue-template-compiler section, re-generate the Single File Component structure  Example: genSection('template', { attrs: { foo: 'bar' }, content: '<h1>Hello World!</h1>' })  => '<template foo="bar"><h1>Hello World</h1></template>'
348781
function genSection(tag, section) {
    if (!section) {
        return '';
    }
    const attrs = genAttrs(section.attrs);
    const content = section.content || '';
    return `<${tag}${attrs}>${content}</${tag}>\n`;
}
680183
function parseComponent (
  content,
  options
 ) {
  if ( options === void 0 ) options = {};

  var sfc = {
    template: null,
    script: null,
    styles: [],
    customBlocks: []
  };
  var depth = 0;
  var currentBlock = null;

  function start (
    tag,
    attrs,
    unary,
    start,
    end
  ) {
    if (depth === 0) {
      currentBlock = {
        type: tag,
        content: '',
        start: end,
        attrs: attrs.reduce(function (cumulated, ref) {
          var name = ref.name;
          var value = ref.value;

          cumulated[name] = value || true;
          return cumulated
        }, Object.create(null))
      };
      if (isSpecialTag(tag)) {
        checkAttrs(currentBlock, attrs);
        if (tag === 'style') {
          sfc.styles.push(currentBlock);
        } else {
          sfc[tag] = currentBlock;
        }
      } else { // custom blocks
        sfc.customBlocks.push(currentBlock);
      }
    }
    if (!unary) {
      depth++;
    }
  }

  function checkAttrs (block, attrs) {
    for (var i = 0; i < attrs.length; i++) {
      var attr = attrs[i];
      if (attr.name === 'lang') {
        block.lang = attr.value;
      }
      if (attr.name === 'scoped') {
        block.scoped = true;
      }
      if (attr.name === 'module') {
        block.module = attr.value || true;
      }
      if (attr.name === 'src') {
        block.src = attr.value;
      }
    }
  }

  function end (tag, start, end) {
    if (depth === 1 && currentBlock) {
      currentBlock.end = start;
      var text = deindent(content.slice(currentBlock.start, currentBlock.end));
      // pad content so that linters and pre-processors can output correct
      // line numbers in errors and warnings
      if (currentBlock.type !== 'template' && options.pad) {
        text = padContent(currentBlock, options.pad) + text;
      }
      currentBlock.content = text;
      currentBlock = null;
    }
    depth--;
  }

  function padContent (block, pad) {
    if (pad === 'space') {
      return content.slice(0, block.start).replace(replaceRE, ' ')
    } else {
      var offset = content.slice(0, block.start).split(splitRE).length;
      var padChar = block.type === 'script' && !block.lang
        ? '//\n'
        : '\n';
      return Array(offset).join(padChar)
    }
  }

  parseHTML(content, {
    start: start,
    end: end
  });

  return sfc
}
334035
function (f, content) {
    var path = config.getLayout(f);
    if (!path) return content;
    if (!fss.exists(path)) return content;
    return compile(f, fss.readFile(path),
        _.extend(templateData({}), { content: content }));
}
904857
function compileTemplate(name) {
  var filename = path.join(__dirname, "templates", name + '.hjs');
  var contents = fs.readFileSync(filename);
  return hogan.compile(contents.toString());
}
1082526
function() {
            var self = this;

            this.template = this.options.template;
            this.args = this.options.args || {};

            // Related view
            this.view = this.options.view || null;

            // Init template context
            _.extend(this.args, {
                "_": _,
                "hr": {
                    "configs": configs,
                    "urls": Urls,
                    "i18n": I18n,
                    "offline": Offline
                },
                "view": {
                    "component": function(cid, args, name, subid) {
                        name = name || cid;

                        if (!self.view) {
                            throw new Error("Error in template " + self.template + " : try to import component in a non view-related template ");
                        }

                        if (Template.components[cid] == null) {
                            throw new Error("Error in template " + self.template + " : try to import component "+cid);
                        }

                        var view = new Template.components[cid].Class(args || {}, self.view);
                        
                        self.view.addComponent(name, view);

                        var component = $("<component/>", {
                            "data-component": view.cid
                        });

                        return component[0].outerHTML;
                    }
                },
                "template": {
                    "args": this.args,
                    "name": this.template,
                    "import": function(name, args, cname) {
                        cname = cname || name;
                        return this.args.view.component("template", {template: name, args: args}, cname);
                    },
                    "htmlid": function(h) {
                        return _.escape(h);
                    }
                }
            }, Template.options);

            return this;
        }
1250887
function getComponents(templateSrc, filename, options){
  var $ = cheerio.load('<div>' + templateSrc + '</div>');
  var components = [];

  var nodeIndex = 0;

  $('*').contents().map(function(index, $el) {
  
    if ($el.type === 'comment') {
      var src = $el.data.trim();

      // keyword check
      if(isComponentComment(src, options.keyword)){
        src = src.substring(options.keyword.length);
        var meta = YAML.safeLoad(src) || {};
        
        var nodes = getComponentHtml($, $el, $.html($($el).nextAll()), options.keyword, meta);
        var html = nodes.filter(function(node) { 
          return (node.trim() !== '');
        }).join('\n');

        var output = render(html, meta, options.block);

        var component = {
          meta: meta,
          file: filename,
          output: output.trim()
        };

        // push comment
        return components.push(component);
      }
    }
  }.bind(this));

  return components;
}
860730
function template(
  { template, types: t },
  opts,
  { imports, componentName, props, jsx, exports },
) {
  const name = componentName.name.replace('Svg', '');

  jsx
    .openingElement
    .attributes = [
      t.jsxAttribute(
        t.jsxIdentifier('aria-label'),
        t.stringLiteral(`icon_${name}`)
      ),
      ...jsx.openingElement.attributes
    ];

  const titleElement = t.jsxElement(
    t.jsxOpeningElement(t.jsxIdentifier('title'), []),
    t.jsxClosingElement(t.jsxIdentifier('title')),
    [t.jsxText(`${name}`)],
  )

  jsx.children = [titleElement, ...jsx.children];

  return template.ast`
    ${imports}
    import withIcon from './withIcon';
    const ${name} = (${props}) => ${jsx}
    export default withIcon(${name});
  `
}
63931
function compileTemplate(name) {
        // Directive compile function
        return function (tElement, tAttrs, transclude) {
            var rootElement = document.createElement("div");
            Object.keys(tAttrs).forEach(function (key) {
                if (key[0] !== '$') {
                    rootElement.setAttribute(key, tAttrs[key]);
                }
            });
            var immediateToken;
            // Directive link function
            return function ($scope, elements, attrs, parents) {
                var parent = parents.reduce(function (found, item) { return found || item; });
                parent[name] = function (itemPromise) {
                    // Actual item renderer
                    return WinJS.Promise.as(itemPromise).then(function (item) {
                        var itemScope = $scope.$new();
                        itemScope.item = item;
                        var result = rootElement.cloneNode(false);
                        transclude(itemScope, function (clonedElement) {
                            for (var i = 0, len = clonedElement.length; i < len; i++) {
                                result.appendChild(clonedElement[i]);
                            }
                        });
                        WinJS.Utilities.markDisposable(result, function () {
                            itemScope.$destroy();
                        });
                        immediateToken = immediateToken || setImmediate(function () {
                            immediateToken = null;
                            itemScope.$apply();
                        });
                        return result;
                    })
                };
            };
        };
    }
309556
function build( tmplItem, nested, content ) {
		// Convert hierarchical content into flat string array 
		// and finally return array of fragments ready for DOM insertion
		var frag, ret = content ? jQuery.map( content, function( item ) {
			return (typeof item === "string") ? 
				// Insert template item annotations, to be converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
				(tmplItem.key ? item.replace( /(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" + tmplItem.key + "\" $2" ) : item) :
				// This is a child template item. Build nested template.
				build( item, tmplItem, item._ctnt );
		}) : 
		// If content is not defined, insert tmplItem directly. Not a template item. May be a string, or a string array, e.g. from {{html $item.html()}}. 
		tmplItem;
		if ( nested ) {
			return ret;
		}

		// top-level template
		ret = ret.join("");

		// Support templates which have initial or final text nodes, or consist only of text
		// Also support HTML entities within the HTML markup.
		ret.replace( /^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function( all, before, middle, after) {
			frag = jQuery( middle ).get();

			storeTmplItems( frag );
			if ( before ) {
				frag = unencode( before ).concat(frag);
			}
			if ( after ) {
				frag = frag.concat(unencode( after ));
			}
		});
		return frag ? frag : unencode( ret );
	}
72936
function renderCustomTemplate() {

	var that = this,
	    child,
	    vars = {},
	    i;

	for (i = 0; i < this.children.length; i++) {
		child = this.children[i];

		if (!child.getAttribute) {
			continue;
		}

		if (child.getAttribute('slot')) {
			vars[child.getAttribute('slot')] = child;
		}
	}

	Hawkejs.removeChildren(this);

	return Fn.series(function renderTemplate(next) {

		var template = that.constructor.compiled_template || that.constructor.template_file;

		that.hawkejs_renderer.renderTemplate(template, {self: that}, String(c++)).done(next);
	}, function assembleBlock(next, template) {
		template.target_block.assemble().done(next);
	}, function assembledBlock(next, block) {

		var slots,
		    slot,
		    name,
		    i;

		for (i = 0; i < block.lines.length; i++) {
			that.append(block.lines[i]);
		}

		slots = Hawkejs.getElementsByAttribute(that, 'data-he-slot');

		for (i = 0; i < slots.length; i++) {
			slot = slots[i];
			name = slot.dataset.heSlot;

			if (vars[name]) {
				Hawkejs.replaceChildren(slot, vars[name].childNodes);
			}
		}

		next();
	}, null);
}
551632
function compileVueToRn(resource) {
  const code = resource.toString();
  const cparsed = compiler.parseComponent(code, { pad: 'line' });

  // console.log(cparsed);

  let output = '';
  let mappings = '';

  // add react-vue import
  output += `import ${constants.VUE}, { observer as ${
    constants.OBSERVER
    } } from 'vue-native-core'`;
  output += '\n';

  // // add react import
  // output += `import ${constants.REACT} from 'react'`
  // output += '\n';

  // add react-native import
  output += `import ${constants.REACT_NATIVE} from 'react-native'`;
  output += '\n';

  // add prop-type import
  output += `import ${constants.PROP_TYPE} from 'prop-types'`;
  output += '\n';

  // add component builder import
  output += `import { buildNativeComponent as ${
    constants.BUILD_COMPONENT
    } } from 'vue-native-helper'`;
  output += '\n';

  // parse template
  const template = cparsed.template;

  //Consider the start of template for debugging
  //
  let templateStartIndex = code.indexOf("<");
  let tempStringBeforeStart = code.substring(0, templateStartIndex);
  let templateLineNumber = tempStringBeforeStart.split(splitRE).length - 1;

  // Get tags and location of tags from template
  //
  let nodes = [];
  const templateFragments = parse5.parseFragment(cparsed.template.content, { sourceCodeLocationInfo: true });
  if (templateFragments.childNodes) {
    traverse(templateFragments, nodes);
  }


  let templateParsed = DEFAULT_OUTPUT.template;
  if (template) {
    const templateContent = template.content.replace(/\/\/\n/g, '').trim();
    if (templateContent) {
      templateParsed = parseTemplate(templateContent);
    }
  }

  // add render dep import
  output += templateParsed.import;
  output += '\n';

  // parse script
  const script = cparsed.script;
  let scriptParsed = DEFAULT_OUTPUT.script;
  if (script) {
    const scriptContent = script.content.replace(/\/\/\n/g, '').trim();
    scriptParsed = parseScript(scriptContent);
    mappings = generateSourceMap(code);
  }

  if (mappings) {
    // Start of the script content
    //
    var beforeLines = output.split(splitRE).length;
    // Start of the script content of the original code
    //
    var scriptLine = code.slice(0, cparsed.script.start).split(splitRE).length + 1;
    var exportDefaultIndex = code.indexOf('export default');
    var tempString = code.substring(0, exportDefaultIndex);
    var exportDefaultLineNumber = tempString.split('\n').length;
  }

  // add vue options
  output += scriptParsed;
  output += '\n\n';

  var endLines = output.split(splitRE).length - 1;
  for (; scriptLine < endLines; scriptLine++) {
    //Skip export default line
    if (scriptLine !== exportDefaultLineNumber) {
      mappings.addMapping({
        source: mappings._hashedFilename,
        generated: {
          line: beforeLines,
          column: 0
        },
        original: {
          line: scriptLine,
          column: 0
        }
      });
    }
    beforeLines++;
  }

  // add render funtion
  let beautifiedRender = beautify(addvm(templateParsed.render, { indent_size: 2 }));
  output += beautifiedRender;
  output += '\n\n';

  // Get last line of render code
  //
  let renderEndLine = beautifiedRender.split(splitRE).length - 1;

  // Search Elements and postion based on render function
  //
  var reactVueElementRegex = /__react__vue__createElement/;
  let foundLines = lineNumber(beautifiedRender, reactVueElementRegex);
  if (mappings) {
    foundLines.forEach((line, index) => {
      let renderJsLine = endLines + line.number;
      if (foundLines[index + 1]) {
        for (let i = line.number; i < foundLines[index + 1].number; i++) {
          // Add Mapping
          if (nodes[index]) {
            mappings.addMapping({
              source: mappings._hashedFilename,
              generated: {
                line: renderJsLine++,
                column: 0
              },
              original: {
                line: nodes[index].startTag.startLine + templateLineNumber,
                column: 0
              }
            });
          }
        }
      } else if (nodes[index] && nodes[index].startTag) {
        // Last Line
        for (let i = line.number; i < renderEndLine; i++) {
          // Add Mapping
          mappings.addMapping({
            source: mappings._hashedFilename,
            generated: {
              line: renderJsLine++,
              column: 0
            },
            original: {
              line: nodes[index].startTag.startLine + templateLineNumber,
              column: 0
            }
          });
        }
      }
    });
  }

  // parse css
  const styles = cparsed.styles;
  let cssParsed = {};
  styles.forEach(function (v) {
    const cssAst = cssParse(v.content);
    cssParsed = Object.assign({}, cssParsed, parseCss(cssAst));
  });

  // add css obj
  output += `const ${constants.CSS} = ${JSON.stringify(cssParsed)}`;
  output += '\n\n';

  // add builder
  output += `const ${constants.COMPONENT_BUILDED} = ${
    constants.BUILD_COMPONENT
    }(${constants.TEMPLATE_RENDER}, ${constants.SCRIPT_OPTIONS}, {Component: ${
    constants.COMPONENT
    }, PropTypes: ${constants.PROP_TYPE}, Vue: ${constants.VUE}, ReactNative: ${
    constants.REACT_NATIVE
    }, css: ${constants.CSS}})`;
  output += '\n\n';

  // export default
  output += `export default ${constants.OBSERVER}(${
    constants.COMPONENT_BUILDED
    })`;

  // beautiful
  // output = beautify(output, { indent_size: 2 });
  return { output, mappings: mappings ? mappings.toJSON() : null };

  // fs.writeFile(name.replace(FILTER, '.js'), output, function(err) {
  //   if (err) {
  //     throw err;
  //   }
  // });
}
1258549
function renderTemplate(fragment, templateName) {
    if (templateName === 'none') return fragment._txt;
    var t = generator.template$[templateName];
    if (!t) {
      log('Unknown template %s for %s, using default.', templateName, fragment._href);
      t = generator.template$.default;
    }

    var out;
    try { out = t(fragment); }
    catch(err) {
      var msg = u.format('Error rendering %s\n\ntemplate: %s\n',
                         fragment._href, templateName, err.stack || err);
      log(msg);
      out = opts.production ? '' : '<pre>' + esc(msg) + '</pre>';
    }

    return out;
  }
970285
function (section, skipInsertHTML, refreshArgs) {
            // PROFILING // var profilingId = this.$startMeasure("Inserting section in DOM from " +
            // PROFILING // this.tplClasspath);
            var differed;
            var params = this._cfg;
            var tpl = this._tpl;
            var domElt = section.id ? section.getDom() : params.tplDiv;

            if (domElt) {
                if (!skipInsertHTML) {
                    section.insertHTML(domElt, refreshArgs);
                }
                if (!section.id) {
                    // the whole template is being refreshed; let's apply the correct size
                    // to its DOM container
                    ariaTemplatesLayout.setDivSize(domElt, tpl.$width, tpl.$height, 'hidden');
                }

                // update expando of container
                ariaUtilsDelegate.addExpando(domElt, section.delegateId);

                differed = section.initWidgets();
                this.__processDifferedItems(differed);
            } else {
                // TODO: LOG ERROR
            }
            if (!skipInsertHTML) {
                // Redundant, but makes sure that insertSection doesn't dispose the template
                this.$assert(743, params.tplDiv && tpl);
                ariaUtilsDom.refreshDomElt(params.tplDiv);
            }
            // PROFILING // this.$stopMeasure(profilingId);
        }
1115314
function (template, data) {
            var p;
            for (p in data) {
                if (data.hasOwnProperty(p)) {
                    template = template.replace(new RegExp('\\{\\{' + p + '\\}\\}', 'g'), data[p]);
                }
            }
            return template;
        }
320056
function parseTemplate(code) {
  const obj = compiler.nativeCompiler(code);
  return {
    import: obj.importCode,
    render: `const ${constants.TEMPLATE_RENDER} = ${obj.renderCode}`
  };
}
1650
function createDomElementFromTemplate(html) {
    //match container markers like <@element/>
    let containerTags = html.match(rContainerGlobal) || [];

    for (let containerTag of containerTags) {
        let [, containerName, attrs = ''] = rContainer.exec(containerTag);
        let template = `<script type="x" ${ATTR}="${containerName}">${attrs.trim()}</script>`;

        html = html.split(containerTag).join(template);
    }

    //match attribute markers like <span @element></span>
    let allTags = html.match(rTags) || [];

    for (let tag of allTags) {
        let result = rAttr.exec(tag);

        if (result) {
            let elName = result[1];
            html = html.split(tag).join(tag.replace(`@${elName}`, `${ATTR}="${elName}"`));
        }
    }

    return $.create(html.trim());
}
409310
function TemplateFileLog(src, target) {
	this.templateFile = {
		source: src,
		target: target
	};
	this.isCompilationPerfect = true;
	this.templateTagLogs = new Table({
		chars: {
			'top-mid': '',
			'bottom-mid': '',
			'middle': '',
			'mid-mid': '',
		},
		style: {},
	});
}