Render mustache into html for complex directory structure
 Loop through each directory matched to a set of mustache classes/subclasses
199865
def mustache_build_folder_structure(logic_file, parent = nil)
      logic_file.each do |dir, mustaches|
        dir = [parent, dir].join("/")

        mustaches.each do |mustache|
          # Get the name of the template class
          template_class = (mustache.is_a? Hash) ? mustache.keys.first : mustache
          # Get the name of the template file
          template_file = camelcase_to_underscore(template_class)
          # If the template class is an array of other classes, then these inherit from it
          if mustache[template_class].is_a? Array
            mustache[template_class].each do |logic_file|
              if logic_file.is_a? Hash
              # If the logic file is an array, then treat it like a folder and recurse
                mustache_build_folder_structure(logic_file, dir)
              else
              # If the logic file is a single file, then render the template
                mustache_template_build(dir, template_file, logic_file)
              end
            end
          else
          # Base case: If the logic file is not an array of clases, render the template
            mustache_template_build(dir, template_file, template_class)
          end
        end
      end
    end
1014901
function template(pattern) {
    return app.src(pattern, { cwd: path.join(__dirname, 'templates') })
      .pipe(app.renderFile('*')).on('error', console.error)
      .pipe(app.conflicts(app.cwd))
      .pipe(app.dest(app.options.dest || app.cwd));
  }
415099
def render_archive(entries):
    """"""
    context = GLOBAL_TEMPLATE_CONTEXT.copy()
    context['entries'] = entries
    _render(context, 'archive_index.html',
            os.path.join(CONFIG['output_to'], 'archive/index.html')),
26503
function loadPartials(template, templatePath) {
    var templateDir = path.dirname(templatePath)

    var partialRegexp = new RegExp(
      escapeRegex(mustache.tags[0]) +
        '>\\s*(\\S+)\\s*' +
        escapeRegex(mustache.tags[1]),
      'g'
    )

    var partialMatch
    while ((partialMatch = partialRegexp.exec(template))) {
      var partialName = partialMatch[1]

      if (!partials[partialName]) {
        try {
          var partialPath = null
          var partial = null

          // ignore `partial` with file extension.
          // e.g.
          //   1, `{{> ./path/to/partial.html }}`
          //   2, `{{> ./path/to/partial. }}`
          if (path.extname(partialName) !== '') {
            partialPath = path.resolve(templateDir, partialName)
            partial = fs.readFileSync(partialPath, 'utf8')
          } else {
            // ignore `partial` file is exists without file extension.
            // e.g.
            //   1, `{{> ./path/to/partial }}` is exists.
            //   2, `{{> ./path/to/.partial }}` is exists.
            partialPath = path.resolve(templateDir, partialName)

            if (fs.existsSync(partialPath)) {
              partial = fs.readFileSync(partialPath, 'utf8')
            } else {
              // or check if `partial + options.extension` is exists.
              // e.g.
              //   if `options.extension` equals ".html":
              //   the `{{> ./path/to/partial }}` will load
              //   `./path/to/partial.html`.
              if (typeof options.extension === 'string') {
                partialPath = path.resolve(
                  templateDir,
                  partialName + options.extension
                )

                if (fs.existsSync(partialPath)) {
                  partial = fs.readFileSync(partialPath, 'utf8')
                }
              }

              // when `options.extension` is not a string or
              // `partialName + options.extension` does not exists.
              // try use `.mustache` extension to load `partial` file.
              if (partial === null) {
                partialPath = path.resolve(
                  templateDir,
                  partialName + '.mustache'
                )

                partial = fs.readFileSync(partialPath, 'utf8')
              }
            }
          }

          partials[partialName] = partial
          loadPartials.call(this, partial, partialPath)
        } catch (ex) {
          this.emit(
            'error',
            new PluginError(
              'gulp-mustache',
              // use `ex.message` property instead of `partialPath`,
              // because `this.emit()` seems not a sync method.
              // also the `ex.message` property provide more details
              // about error information.
              'Unable to load partial file: ' + ex.message
            )
          )
        }
      }
    }
  }
609407
function renderProblemFiles(files, currDir) {
	return _.map(files, function(fileDetails) {
		return filesTemplate({
			fileId: _.camelCase(fileDetails.filePath),
			filePath: fileDetails.filePath.replace(currDir, ''),
			errorCount: fileDetails.errorCount,
			warningCount: fileDetails.warningCount
		});
	}).join('\n');
}
1165619
def makeHTML(self,mustachepath,htmlpath):
        ''' '''
        subs = dict()
        if self.title:
            subs["title"]=self.title
            subs["has_title"]=True
        else:
            subs["has_title"]=False
        subs["font_size"] = self.font_size
        subs["font_family"] = self.font_family
        subs["colorscheme"] = self.colorscheme
        subs["title_color"] = self.title_color
        subs["bgcolor"] = self.bgcolor
        with open(mustachepath,'r') as infile:
            mustache_text = pystache.render(infile.read(), subs)
            with open(htmlpath,'w+') as outfile:
                outfile.write(mustache_text)
1369411
def render(template, dest, **kwargs):
    '''
    '''

    dest_dir = dirname(dest)
    if dest_dir and not exists(dest_dir):
        makedirs(dest_dir)

    template = environment.get_template(template)
    text = template.render(**kwargs)

    f = open(dest, 'wb')
    f.write(text.encode('utf-8'))
    f.close()
667699
def get_template_context(src, container="div", classes="", inner_classes="", alt="", background_image=False, no_css=False, aria_hidden=False):
    """"""
    context = {
        "container": container,
        "classes": classes,
        "aspect_padding_bottom": aspect_ratio_percent(src),
        "alt": alt,
        "background_image": background_image,
        "no_css": no_css,
        "inner_classes": inner_classes,
        "aria_hidden": aria_hidden,
    }

    # We can't do any of the srcset (or JS switching fallback) if we don't
    # have a thumbnail library installed.
    if not get_thumbnail_engine():
        context["image"] = src
        return context

    sizes = get_image_sizes(src)
    context["image_sizes"] = sizes

    # Set the first image in the list as the one to be rendered initially
    # (pre-JS-fallback). `if sizes` might not be a necessary check...
    context["image"] = sizes[0]

    context["image_sizes_json"] = json.dumps(sizes)
    srcset_items = ["{} {}w".format(size["url"], size["width"]) for size in sizes]

    context["image_sizes_srcset"] = ", ".join(srcset_items)
    return context
789928
public static function loadHelpers() {
		
		// set-up helper container
		$helpers = array();
		
		// load defaults
		$helperDir = Config::getOption("sourceDir").DIRECTORY_SEPARATOR."_mustache-components/helpers";
		$helperExt = Config::getOption("mustacheHelperExt");
		$helperExt = $helperExt ? $helperExt : "helper.php";
		
		if (is_dir($helperDir)) {
			
			// loop through the filter dir...
			$finder = new Finder();
			$finder->files()->name("*\.".$helperExt)->in($helperDir);
			$finder->sortByName();
			foreach ($finder as $file) {
				
				// see if the file should be ignored or not
				$baseName = $file->getBasename();
				if ($baseName[0] != "_") {
					
					include($file->getPathname());
					
					// $key may or may not be defined in the included file
					// $helper needs to be defined in the included file
					if (isset($helper)) {
						if (!isset($key)) {
							$key = $file->getBasename(".".$helperExt);
						}
						$helpers[$key] = $helper;
						unset($helper);
						unset($key);
					}
					
				}
				
			}
			
		}
		
		return $helpers;
		
	}
879123
function renderTemplateFile(engine, filePath, context) {
    var loader = engine.getLoader();

    // Resolve the filePath
    var resolvedFilePath = loader.resolve(null, filePath);

    return Promise()
    .then(function() {
        if (!loader.async) {
            return loader.getSource(resolvedFilePath);
        }

        var deferred = Promise.defer();
        loader.getSource(resolvedFilePath, deferred.makeNodeResolver());
        return deferred.promise;
    })
    .then(function(result) {
        if (!result) {
            throw error.TemplateError(new Error('Not found'), {
                filename: filePath
            });
        }

        return render(engine, result.path, result.src, context);
    });

}
360763
function renderModule(context, options) {
	var  cacheKey
		,modSourceTemplate
		,mergedData
		,html
	;

	// this check is used when rendering isolated modules or views for development and testing (in the default layout!).
	// skip any modules that are not THE module or THE view.
	// view: skip all modules that have the attribute _isLayout="true"
	// module: skip all other modules
	if (
		context.skipModules === true ||                         // case: module
		context.skipModules == 'layout' && options._isLayout    // case: view
		)
	{ return ''; }

	options.template = options.template || options.name;
	options.tag = options.tag || defaults.tag;
	options.data = options.data || {};
	options.data.moduleNestingLevel = typeof context.moduleNestingLevel === 'undefined' ? 0 : context.moduleNestingLevel + 1;
	autoIncrementIndent = options.data.moduleNestingLevel > 0 ? 1 : false;
	options.data.indent = options.indent || autoIncrementIndent || context.indent || 0;

	// merge the request context and data in the module include, with the latter trumping the former.
	mergedData = _.merge({}, context, options.data);

	// create a unique identifier for the module/template combination
	cacheKey = options.name + ' ' + options.template;

	// If addTest exists it means we should pass module options into it for later client-side module testing.
	context._locals && context._locals.addTest && context._locals.addTest(options);

	// force reading from disk in development mode
	NODE_ENV == 'development' && (cache[cacheKey] = null);

	// if the module/template combination is cached use it, else read from disk and cache it.
	modSourceTemplate = cache[cacheKey] || (cache[cacheKey] = getModTemplate(options));

	// render the module source in the locally merged context
	// moduleSrc is a {{variable}} in the moduleWrapper template
	try {
		options.moduleSrc = modSourceTemplate.fn(mergedData);
	}
	catch (e) {
		if (process.env.NODE_ENV != 'test') {
			if (e instanceof RenderError)   // if this is our error from a nested template rethrow it.
				throw e;
			else                            // if this is the original Handlebars error, make it useful
				throw new RenderError('Module: ' + options.name + ', Template: ' + options.template + cfg.templateExtension +'\n'+ e.toString().replace(/^Error/, 'Reason'));
		}
	}


	if (options.noWrapper) {
		html = options.moduleSrc;
	}
	else {
		// if we have a persisted read error, add the error class to the module.
		modSourceTemplate.err && (options.classes = options.classes ? options.classes + ' xtc-error' : 'xtc-error');

		if (annotateModules) {
			options._module = modSourceTemplate.name;
			options._file = modSourceTemplate.file;
			options._path = modSourceTemplate.path;
			options._repository = modSourceTemplate.repository;
		}

		// render the wrapper template
		html = wrapperFn(options);
	}

	// manage indentation
	if (mergedData.indent) {
		html = utils.indent(html, mergedData.indent, cfg.indentString);
	}

	return html;
}
990619
def render_template(self):
        """"""
        self._parse_paths()
        context = dict(napp=self._napp.__dict__, paths=self._paths)
        self._save(context)
385729
def renderList(l, markDownHelp, settings=None):
    
    if len(l) == 0:
        return []
    if markDownHelp:
        from sphinxarg.markdown import parseMarkDownBlock
        return parseMarkDownBlock('\n\n'.join(l) + '\n')
    else:
        all_children = []
        for element in l:
            if isinstance(element, str):
                if settings is None:
                    settings = OptionParser(components=(Parser,)).get_default_values()
                document = new_document(None, settings)
                Parser().parse(element + '\n', document)
                all_children += document.children
            elif isinstance(element, nodes.definition):
                all_children += element

        return all_children
183431
def render_source(output_dir, package_spec):
  
  path, name = package_spec.filepath
  module_prefix = "SwiftNav.SBP"
  module_name = camel_case(name)
  full_module_name = ".".join([module_prefix, module_name])
  destination_filename = "%s/src/SwiftNav/SBP/%s.hs" % (output_dir, module_name)
  py_template = JENV.get_template(MESSAGES_TEMPLATE_NAME)
  module_includes = [".".join([module_prefix] + [camel_case(j) for j in i.split(".")[:-1]])
                     for i in package_spec.includes]

  with open(destination_filename, 'w') as f:
    f.write(py_template.render(msgs=package_spec.definitions,
                               description=package_spec.description,
                               module_name=full_module_name,
                               module_includes=module_includes))
842852
function createFiles (files, argv, templates, cb) {
  if (!templates) {
    const parent = path.resolve(module.parent.filename)
    templates = path.join(parent, '../templates')
  }

  const dir = argv.directory
  parallel(files.map(mapFn), cb)

  function mapFn (file) {
    const tempDir = path.resolve(templates)
    const inFile = path.join(tempDir, file.replace(/^\./, '_.'))
    const outFile = path.resolve(path.join(dir, file))

    return function (done) {
      fs.createReadStream(inFile)
        .pipe(through(transform))
        .pipe(fs.createWriteStream(outFile))
        .on('error', done)
        .on('finish', function () {
          process.stdout.write('write: ' + outFile + '\n')
          done()
        })

      function transform (chunk, enc, cb) {
        const str = chunk.toString()
        const mt = mustache.render(str, argv)
        cb(null, mt)
      }
    }
  }
}
1231901
function(id, src) {
                    return "can.Mustache(function(" + ARG_NAMES + ") { " + new Mustache({
                            text: src,
                            name: id
                        })
                        .template.out + " })";
                }
520349
def render_python_template_to(src, dest, subsd, only_update=False,
                              prev_subsd=None, create_dest_dirs=True,
                              logger=None):
        
        if only_update:
            if subsd == prev_subsd:
                if not missing_or_other_newer(dest, src):
                    if logger:
                        msg = ("Did not re-render {}. "
                               "(destination newer + same dict)")
                        logger.info(msg.format(src))
                    return

        with open(src, 'rt') as ifh:
            data = ifh.read()  # Don't go crazy on file size...

        if create_dest_dirs:
            dest_dir = os.path.dirname(dest)
            if not os.path.exists(dest_dir):
                make_dirs(dest_dir)

        with open(dest, 'wt') as ofh:
            ofh.write(data % subsd)