Loops through the available Tilt templates
 and registers them as processor engines for
 Sprockets. By default, Sprockets cherry picks
 templates that work for web assets. We need to
 allow use of Haml, Markdown, etc.
495703
def use_all_templates
      Utils.available_templates.each do |ext, template|
        next if engines(ext)
        register_engine ext, template
      end
    end
1119952
function registerTemplates(filepaths, callback) {
    async.map(filepaths, registerTemplate, function (err, templates) {
      if (err) callback(err);
      callback(null, templates);
    });
  }
3969
def select_template(template_name_list, using=None):
    
    if isinstance(template_name_list, six.string_types):
        raise TypeError(
            'select_template() takes an iterable of template names but got a '
            'string: %r. Use get_template() if you want to load a single '
            'template by name.' % template_name_list
        )

    engines = _engine_list(using)
    for template_name in template_name_list:
        for engine in engines:
            try:
                return engine.get_template(template_name)
            except TemplateDoesNotExist as e:
                pass

    if template_name_list:
        raise TemplateDoesNotExist(', '.join(template_name_list))
    else:
        raise TemplateDoesNotExist("No template names provided")
346156
private Templates tryCache(String url) throws Exception {
        Templates x = (Templates) m_cache.get(url);
        if (x == null) {
            synchronized (m_cache) {
                if (!m_cache.containsKey(url)) {
                    TransformerFactory factory = TransformerFactory.newInstance();
                    if (factory.getClass().getName().equals("net.sf.saxon.TransformerFactoryImpl")) {
                        factory.setAttribute(FeatureKeys.VERSION_WARNING, Boolean.FALSE);
                    }
                    StreamSource ss = new StreamSource(getInputStream(url));
                    ss.setSystemId(url);
                    x = factory.newTemplates(ss);
                    m_cache.put(url, x);
                }
            }
        }
        return x;
    }
312889
def _represent_fold(fold_location, fold_ir_blocks):
    """"""
    start_let_template = u'$%(mark_name)s = %(base_location)s'
    traverse_edge_template = u'.%(direction)s("%(edge_name)s")'
    base_template = start_let_template + traverse_edge_template
    edge_direction, edge_name = fold_location.get_first_folded_edge()
    mark_name, _ = fold_location.get_location_name()
    base_location_name, _ = fold_location.base_location.get_location_name()

    validate_safe_string(mark_name)
    validate_safe_string(base_location_name)
    validate_safe_string(edge_direction)
    validate_safe_string(edge_name)

    template_data = {
        'mark_name': mark_name,
        'base_location': base_location_name,
        'direction': edge_direction,
        'edge_name': edge_name,
    }
    final_string = base_template % template_data

    for block in fold_ir_blocks:
        if isinstance(block, Filter):
            final_string += u'[' + block.predicate.to_match() + u']'
        elif isinstance(block, Traverse):
            template_data = {
                'direction': block.direction,
                'edge_name': block.edge_name,
            }
            final_string += traverse_edge_template % template_data
        elif isinstance(block, MarkLocation):
            # MarkLocation blocks inside a fold do not result in any MATCH output.
            pass
        else:
            raise AssertionError(u'Found an unexpected IR block in the folded IR blocks: '
                                 u'{} {} {}'.format(type(block), block, fold_ir_blocks))

    # Workaround for OrientDB's inconsistent return type when filtering a list.
    # https://github.com/orientechnologies/orientdb/issues/7811
    final_string += '.asList()'

    return final_string
491529
def template(*args, **kwargs):
    '''
    
    '''
    tpl = args[0] if args else None
    template_adapter = kwargs.pop('template_adapter', SimpleTemplate)
    if tpl not in TEMPLATES or DEBUG:
        settings = kwargs.pop('template_settings', {})
        lookup = kwargs.pop('template_lookup', TEMPLATE_PATH)
        if isinstance(tpl, template_adapter):
            TEMPLATES[tpl] = tpl
            if settings: TEMPLATES[tpl].prepare(**settings)
        elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl:
            TEMPLATES[tpl] = template_adapter(source=tpl, lookup=lookup, **settings)
        else:
            TEMPLATES[tpl] = template_adapter(name=tpl, lookup=lookup, **settings)
    if not TEMPLATES[tpl]:
        abort(500, 'Template (%s) not found' % tpl)
    for dictarg in args[1:]: kwargs.update(dictarg)
    return TEMPLATES[tpl].render(kwargs)
11613
function(template) {
      if (template) {
        // make a shadow root
        var root = this.createShadowRoot();
        // stamp template
        // which includes parsing and applying MDV bindings before being
        // inserted (to avoid {{}} in attribute values)
        // e.g. to prevent <img src="images/{{icon}}"> from generating a 404.
        var dom = this.instanceTemplate(template);
        // append to shadow dom
        root.appendChild(dom);
        // perform post-construction initialization tasks on shadow root
        this.shadowRootReady(root, template);
        // return the created shadow root
        return root;
      }
    }
746102
def tilt(*args, &block)
      filter(Rake::Pipeline::Web::Filters::TiltFilter, *args, &block)
    end
1161495
function renderTemplate(impl, targetFile){
	var stappoImpl = fs.readFileSync(impl, "utf8");
	return gulp.src([targetFile])
		.pipe(replace('/*__stappo_impl__*/', stappoImpl));
}
63567
def sprockets(source_file, opts={})
      require 'sprockets'
      source_path = source_file || opt[:main] || opt[:from]
      env = ::Sprockets::Environment.new site.root
      env.append_path File.expand_path(File.join site.source_path, File.dirname(source_path))
      env.append_path site.source_path
      # env.append_path File.dirname(source_path)
      [opts[:paths]].flatten.each do |path|
        env.append_path(path) unless path.nil?
      end
      content= env[ source_path ].to_s
    rescue LoadError
      raise StandardError, "Sprockets can't be loaded. Please add it to your Gemfile."
    end
1176791
function template(tmpl, data) {
  // Grab the template engine
  var engine = settings['template engine'];

  // Process the template through the template engine
  var content = engine.call(this, tmpl, data);

  // Return the content
  return content;
}
801906
def sprockets_map # :nodoc:
      {}.tap do |map|
        machined.sprockets.each do |sprocket|
          next unless sprocket.compile?
          map[sprocket.config.url] = sprocket
        end
      end
    end
552599
function staticSiteGenerator(options) {

  var buffer = {},
      layoutCache = {},
      templateCache = {},
      markedRenderer = new marked.Renderer();

  options = merge.recursive({
    basePath: '/',
    data: {},
    defaultLayout: false,
    jade: jade,
    jadeOptions: {
      basedir: path.join(process.cwd(), 'src')
    },
    layoutPath: 'layouts',
    marked: marked,
    markedOptions: {
      renderer: markedRenderer
    },
    passThrough: true,
    prettyUrls: true,
    regexpHtml: /\.html$/i,
    regexpMarkdown: /\.(md|markdown)$/i,
    regexpTemplate: /\.jade$/i,
    renderCode: renderCode,
    renderTemplate: renderTemplate,
    renderMarkdown: renderMarkdown,
    slugify: true,
    slugOptions: {
      mode: 'rfc3986',
      remove: /^\./g
    }
  }, options || {});

  options.markedOptions.renderer.code = options.renderCode;
  options.marked.setOptions(options.markedOptions);
  options.jade.filters.markdown = options.renderMarkdown;

  return through.obj(transformChunk);

  /**
   * transforms a stream chunk
   * @param  {object}   chunk    chunk object
   * @param  {string}   encoding file encoding
   * @param  {Function} done     callback
   * @return {undefined}
   */
  function transformChunk(chunk, encoding, done) {
    if (chunk.isNull()) return done();
    if (chunk.isStream()) return this.emit('error', new PluginError(logFlag, 'Streaming not supported'));
    if (
      !(chunk.isMarkdown = options.regexpMarkdown.test(chunk.relative)) &&
      !(chunk.isTemplate = options.regexpTemplate.test(chunk.relative)) &&
      !(chunk.isHtml = options.regexpHtml.test(chunk.relative))
    ) {
      return options.passThrough ? done(null, chunk) : done();
    }
    transformChunkData(chunk);
    if (chunk.data.draft && process.env.NODE_ENV !== 'development') return done();
    if (buffer.hasOwnProperty(chunk.relative)) {
      logDuplicate(chunk);
      return done();
    }
    transformChunkContents.call(this, chunk);
    buffer[chunk.relative] = chunk;
    done(null, chunk);
  }

  /**
   * merge site data, options data, frontmatter data into chunk data
   * @param  {object} chunk stream chunk object
   * @return {object}       chunk with transformed data
   */
  function transformChunkData(chunk) {
    var matter = grayMatter(String(chunk.contents)),
        relPath = chunk.hasOwnProperty('data') && chunk.data.relativePath ?
          chunk.data.relativePath : getRelativePath(chunk.relative),
        absPath = path.normalize(path.join(options.basePath, relPath));
    chunk.data = merge.recursive({},
      options.data,
      {
        basePath: options.basePath,
        relativePath: relPath,
        path: absPath,
        urlPath: options.prettyUrls ? path.dirname(absPath) + '/' : absPath,
        srcBasePath: chunk.base,
        srcRelativePath: chunk.relative,
        srcPath: chunk.path,
        contents: '',
        draft: false,
        layout: options.defaultLayout
      },
      chunk.data || {},
      matter.data
    );
    chunk.contents = new Buffer(matter.content);
    chunk.path = path.join(chunk.base, relPath);
    return chunk;
  }

  /**
   * render chunk contents with markdown renderer, wrap layout, render template
   * @param  {object} chunk stream chunk object
   * @return {object}       chunk with transformed contents
   */
  function transformChunkContents(chunk) {
    var contents = String(chunk.contents);
    try {
      if (chunk.isMarkdown) {
        contents = options.renderMarkdown(contents);
      }
      if (chunk.isTemplate) {
        contents = options.renderTemplate(contents, chunk.data, chunk.data.srcPath);
      }
      chunk.contents = new Buffer(contents);
      if (chunk.data.layout) applyLayout(chunk);
    } catch (err) {
      this.emit('error', new PluginError(logFlag, err.stack || err));
    }
    return chunk;
  }

  /**
   * render a template string with optional data
   * @param  {string} contents template
   * @param  {object} data     optional template data
   * @param  {object} filename optional template path for importing/mergeing
   * @return {string}          rendered template
   */
  function renderTemplate(contents, data, filename) {
    if (!templateCache.hasOwnProperty(contents)) {
      var jadeOptions = merge.recursive({}, options.jadeOptions, {filename: filename});
      templateCache[contents] = options.jade.compile(contents, jadeOptions);
    }
    var locals = merge.recursive({}, data, {locals: locals});
    return templateCache[contents](data);
  }

  /**
   * render a markdown string to html
   * @param  {string} contents markdown
   * @return {string}          html
   */
  function renderMarkdown(contents) {
    return options.marked(contents).trim();
  }

  /**
   * render string of code to highlighted code html structure
   * @param {string}  code source code string
   * @param {string}  lang source code language string
   * @return {string}      html
   */
  function renderCode(code, lang) {
    lang = typeof lang === 'string' && highlightjs.getLanguage(lang) ? lang : false;
    code = lang ? highlightjs.highlight(lang, code).value : highlightjs.highlightAuto(code).value;
    return '<pre><code class="hljs' + (lang ? ' ' + lang : '') + '">' + code + '</code></pre>';
  }

  /**
   * set chunk contents as template data property and render it with a layout
   * @param  {object} chunk stream chunk object
   * @return {object}       chunk with applied layout
   */
  function applyLayout(chunk) {
    chunk.data.contents = String(chunk.contents);
    var layout = getLayout(chunk.data.layout),
        contents = options.renderTemplate(layout.contents, chunk.data, layout.path);
    chunk.contents = new Buffer(contents);
    return chunk;
  }

  /**
   * transform a src file path into an relative url path
   * @param  {string} filePath file path
   * @return {string}          url
   */
  function getRelativePath(filePath) {
    var urlPath = path.join(
      path.dirname(filePath),
      path.basename(filePath, path.extname(filePath))
    );
    if (options.slugify) {
      urlPath = urlPath.split('/').map(function(part) {
        return slug(part, options.slugOptions);
      }).join('/');
    }
    urlPath += !options.prettyUrls || (/(^|\/)index$/i).test(urlPath) ?
      '.html' : '/index.html';
    return urlPath;
  }

  /**
   * read a layout file from given path; store it in cache object for further
   * usage; return object with layout contents and absolute path
   * @param  {string}   layout path to layout
   * @return {object}          layout contents and path
   */
  function getLayout(layout) {
    if (!layoutCache.hasOwnProperty(layout)) {
      var layoutContents = false,
          layoutPath = path.join(
        path.isAbsolute(options.layoutPath) ?
          options.layoutPath : path.join(process.cwd(), options.layoutPath),
        layout
      );
      try {
        layoutContents = fs.readFileSync(layoutPath, 'utf8');
      } catch (err) {
        throw new PluginError(logFlag, 'Could not read layout: \'' + layoutPath + '\'\n');
      }
      layoutCache[layout] = {
        contents: layoutContents,
        path: layoutPath
      };
    }
    return layoutCache[layout];
  }

  /**
   * log possible output overwrite to console
   * @param  {object} chunk stream chunk object
   * @return {undefined}
   */
  function logDuplicate(chunk) {
    log(logFlag,
      chalk.black.bgYellow('WARNING') + ' skipping ' +
      chalk.magenta(chunk.data.srcRelativePath) +
      ' as it would output to same path as ' +
      chalk.magenta(buffer[chunk.relative].data.srcRelativePath)
    );
  }

}
976184
function(raw_blocks) {

		var result = this.asBlocks(this.compileTemplate(raw_blocks));
		if (result.length != 1) Lava.t("Expected: exactly one view, got either several or none.");
		if (result[0].type != 'view' && result[0].type != 'widget') Lava.t("Expected: view, got: " + result[0].type);
		return result[0];

	}
391871
def find_template(views, name, engine)
      yield ::File.join(views, "#{name}.#{@preferred_extension}")

      if Tilt.respond_to?(:mappings)
        Tilt.mappings.each do |ext, engines|
          next unless ext != @preferred_extension and engines.include? engine
          yield ::File.join(views, "#{name}.#{ext}")
        end
      else
        Tilt.default_mapping.extensions_for(engine).each do |ext|
          yield ::File.join(views, "#{name}.#{ext}") unless ext == @preferred_extension
        end
      end
    end
244043
def find_template(views, name, engine)
      yield ::File.join(views, "#{name}.#{@preferred_extension}")
      Tilt.mappings.each do |ext, engines|
        next unless ext != @preferred_extension and engines.include? engine
        yield ::File.join(views, "#{name}.#{ext}")
      end
    end
1033910
def register_templatetags():
    
    from turboengine.conf import settings
    from google.appengine.ext.webapp import template
    for python_file in settings.TEMPLATE_PATH:
        template.register_template_library(python_file)