Applies a similar URL-building technique as Jekyll::Document that takes
 the collection's URL template into account. The default URL template can
 be overriden in the collection's configuration in _config.yml.
165077
def url
      @url ||= begin
        base = if @collection.nil?
                 cleaned_relative_path
               else
                 Jekyll::URL.new(
                   :template     => @collection.url_template,
                   :placeholders => placeholders
                 )
               end.to_s.chomp("/")
        base << extname
      end
    end
118234
function collections(config) {
  config = config || {};

  return function plugin(app, base) {
    if (!utils.isValid(app, 'generate-collections')) return;
    app.define('home', path.resolve.bind(path, os.homedir()));

    /**
     * Options
     */

    app.option(config);

    // add default view collections
    if (!app.files) app.create('files', { viewType: 'renderable'});
    if (!app.includes) app.create('includes', { viewType: 'partial' });
    if (!app.layouts) app.create('layouts', { viewType: 'layout' });
    if (!app.templates) app.create('templates', { viewType: 'renderable' });

    /**
     * Middleware for collections created by this generator
     */

    app.preLayout(/./, function(view, next) {
      if (utils.falsey(view.layout) && !view.isType('partial')) {
        // use the empty layout created above, to ensure that all
        // pre-and post-layout middleware are still triggered
        view.layout = app.resolveLayout(view);
        if (utils.falsey(view.layout)) {
          view.layout = 'empty';
        }
        next();
        return;
      }

      if (view.isType('partial')) {
        view.options.layout = null;
        view.data.layout = null;
        view.layout = null;
        if (typeof view.partialLayout === 'string') {
          view.layout = view.partialLayout;
        }
      }
      next();
    });

    // remove or rename template prefixes before writing files to the file system
    var regex = app.options.templatePathRegex || /./;
    app.templates.preWrite(regex, utils.renameFile(app));
    app.templates.onLoad(regex, function(view, next) {
      var userDefined = app.home('templates', view.basename);
      if (fs.existsSync(userDefined)) {
        view.contents = fs.readFileSync(userDefined);
      }
      utils.stripPrefixes(view);
      utils.parser.parse(view, next);
    });

    // "noop" layout
    app.layout('empty', {content: '{% body %}'});

    // create collections defined on the options
    if (utils.isObject(app.options.create)) {
      for (var key in app.options.create) {
        if (!app[key]) {
          app.create(key, app.options.create[key]);
        } else {
          app[key].option(app.options.create[key]);
        }
      }
    }

    // pass the plugin to sub-generators
    return plugin;
  };
}
1028417
def template(*args, **kwargs):
    
    tpl = args[0] if args else None
    for dictarg in args[1:]:
        kwargs.update(dictarg)
    adapter = kwargs.pop('template_adapter', SimpleTemplate)
    lookup = kwargs.pop('template_lookup', TEMPLATE_PATH)
    tplid = (id(lookup), tpl)
    if tplid not in TEMPLATES or DEBUG:
        settings = kwargs.pop('template_settings', {})
        if isinstance(tpl, adapter):
            TEMPLATES[tplid] = tpl
            if settings: TEMPLATES[tplid].prepare(**settings)
        elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl:
            TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings)
        else:
            TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings)
    if not TEMPLATES[tplid]:
        abort(500, 'Template (%s) not found' % tpl)
    return TEMPLATES[tplid].render(kwargs)
674486
def new(path='.', template=None):
    
    path = abspath(path.rstrip(sep))
    template = template or DEFAULT_TEMPLATE_URL
    render_skeleton(
        template, path,
        include_this=['.gitignore'],
        filter_this=[
            '~*', '*.py[co]',
            '__pycache__', '__pycache__/*',
            '.git', '.git/*',
            '.hg', '.hg/*',
            '.svn', '.svn/*',
        ]
    )
    print(HELP_MSG % (path,))
363701
def url(page)
      @base_url_params ||= begin
                             url_params = merge_get_params(default_url_params)
                             merge_optional_params(url_params)
                           end

      url_params = @base_url_params.dup
      add_current_page_param(url_params, page)

      # Add optional url_builder support
      (@options[:url_builder] || @template).url_for(url_params)
    end
429133
def override_default_templates(self):
        
        if plugs_mail_settings['OVERRIDE_TEMPLATE_DIR']:
            dir_ = plugs_mail_settings['OVERRIDE_TEMPLATE_DIR']
            for file_ in os.listdir(dir_):
                if file_.endswith(('.html', 'txt')):
                    self.overrides[file_] = dir_
1365595
def custom_template_path(name)
      config = ShopConfig.new
      custom_path = config.get('template', 'path')
      if File.exists?("#{custom_path}/#{name}")
        "#{custom_path}/#{name}"
      else
        false
      end
    end
1374841
function template (options) {

    var variables = [], url = expand(options.url, options.params, variables);

    variables.forEach(function (key) {
        delete options.params[key];
    });

    return url;
}
100467
def render(context)
      if      "#{context[@key]}" != "" # Check for page variable
        key = "#{context[@key]}"
      else
        key = @key
      end
      
      key = Liquid::Template.parse(key).render(context)  # Parses and renders some Liquid syntax on arguments (allows expansions)
      
      site = context.registers[:site] # Jekyll site object
      
      key          = key.split
      namespace    = key[0]
      lang         = key[1] || site.config[        'lang']
      default_lang =           site.config['default_lang']
      baseurl      =           site.baseurl
      pages        =           site.pages
      url          = "";
      
      if default_lang != lang
        baseurl = baseurl + "/" + lang
      end
      
      for p in pages
        unless             p['namespace'].nil?
          page_namespace = p['namespace']
          
          if namespace == page_namespace
            permalink = p['permalink_'+lang] || p['permalink']
            url       = baseurl + permalink
          end
        end
      end
      
      url
    end
101479
def substitute_template_values(endpoint, request_type, options={})
      # Gets the proper template for the give CUSTOM_SCHEMA string for this endpoint and substitutes value for it based on give options
      endpoint_templates = @schemas.fetch(request_type.to_sym, nil)
      template = endpoint_templates.fetch(endpoint.to_sym, nil) if endpoint_templates

      if template
        extracted_options, options = extract_template_options(options.merge({endpoint: endpoint}), template)
        # Render out the template
        rendered_template = Liquid::Template.parse(template).render(extracted_options)
      end

      return rendered_template, options
    end
365371
function Template( name, dir){
  this.name = name;
  if( name){
    this.view = this.load( 
      util.format(
        '%s/%s/%s.%s', 
        dir, name, name, 'html'
      )
    );
  }
  return this;
}
1336540
def _buildTemplates(self):
        

        c_mydict = build_class_json(self.ontospy_graph.all_classes)
        JSON_DATA_CLASSES = json.dumps(c_mydict)


        extra_context = {
                        "ontograph": self.ontospy_graph,
         'JSON_DATA_CLASSES' : JSON_DATA_CLASSES,
                        }

        # Ontology - MAIN PAGE
        contents = self._renderTemplate("misc/sigmajs.html", extraContext=extra_context)
        FILE_NAME = "index.html"
        main_url = self._save2File(contents, FILE_NAME, self.output_path)

        return main_url
284304
function getOrCreateTemplateContentsOwner(template) {
    var doc = template.ownerDocument
    if (!doc.defaultView)
      return doc;
    var d = doc.templateContentsOwner_;
    if (!d) {
      // TODO(arv): This should either be a Document or HTMLDocument depending
      // on doc.
      d = doc.implementation.createHTMLDocument('');
      while (d.lastChild) {
        d.removeChild(d.lastChild);
      }
      doc.templateContentsOwner_ = d;
    }
    return d;
  }
370198
def get_templates(self, id_or_uri, start=0, count=-1, filter='', query='', sort=''):
        
        uri = self._client.build_uri(id_or_uri) + "/templates"
        return self._client.get(self._client.build_query_uri(start=start, count=count, filter=filter,
                                                             query=query, sort=sort, uri=uri))
515636
def replace_git_url(generator):
    """"""
    template = g_jinja2.get_template(GIT_TEMPLATE)

    should_cache = generator.context.get('GIT_CACHE_ENABLED')
    cache_location = generator.context.get('GIT_CACHE_LOCATION')

    for article in generator.articles:
        for match in git_regex.findall(article._content):
            params = collections.defaultdict(str)
            repo = match[1]
            filename = match[3]
            branch = match[5]
            hash = match[7]

            params['repo'] = match[1]
            params['filename'] = match[3]
            if match[5]:
                params['branch'] = match[5]
            if match[7]:
                params['hash'] = match[7]

            logger.info('[git]: Found repo {}, filename {}, branch {} and hash {}'.format(repo, filename, branch, hash))
            logger.info('[git]: {}'.format(params))

            body = None if not should_cache else get_cache(cache_location, **params)

            # Fetch the git
            if not body:
                logger.info('[git]: Git did not exist in cache, fetching...')
                response = fetch_git(**params)
                body = get_body(response)

                if should_cache:
                    logger.info('[git]: Saving git to cache...')
                    cache_params = copy.copy(params)
                    cache_params['body'] = body
                    set_cache(cache_location, **cache_params)
            else:
                logger.info('[git]: Found git in cache.')

            # Create a context to render with
            context = generator.context.copy()
            context.update({
                'code': body,
                'footer': 'full',
                'base': __url__,
                'filename': filename,
                'url': git_url(**params)
            })
            replacement = template.render(context)
            article._content = article._content.replace(match[0], replacement)
147377
private static void initURLTemplates( ServletContext servletContext )
    {
        TemplatedURLFormatter formatter = TemplatedURLFormatter.getTemplatedURLFormatter( servletContext );
        if ( formatter == null )
        {
            // get the default template formatter class name from the config file
            formatter = getTemplatedURLFormatter();

            assert formatter != null : "Found a non-null URL formatter";

            // set the TemplatedURLFormatter attribute on the context.
            TemplatedURLFormatter.initServletContext( servletContext, formatter );
        }

        URLTemplatesFactory templatesFactory = URLTemplatesFactory.getURLTemplatesFactory( servletContext );
        if ( templatesFactory == null )
        {
            // URLTemplatesFactory has not been initialized,
            // get a URLTemplatesFactory object from the containerAdapter.
            templatesFactory = PageFlowUtils.createURLTemplatesFactory( servletContext );

            // get the known/req tokens from the default formatter for the factory to use to verify templates
            templatesFactory.setKnownTokens( formatter.getKnownTokens() );
            templatesFactory.setRequiredTokens( formatter.getRequiredTokens() );
            templatesFactory.load( servletContext );

            // set the URLTemplatesFactory attribute on the context.
            URLTemplatesFactory.initServletContext( servletContext, templatesFactory );
        }
    }
435882
def url_for(self, action='view', **kwargs):
        
        app = current_app._get_current_object() if current_app else None
        if app is not None and action in self.url_for_endpoints.get(app, {}):
            endpoint, paramattrs, _external = self.url_for_endpoints[app][action]
        else:
            try:
                endpoint, paramattrs, _external = self.url_for_endpoints[None][action]
            except KeyError:
                raise BuildError(action, kwargs, 'GET')
        params = {}
        for param, attr in list(paramattrs.items()):
            if isinstance(attr, tuple):
                # attr is a tuple containing:
                # 1. ('parent', 'name') --> self.parent.name
                # 2. ('**entity', 'name') --> kwargs['entity'].name
                if attr[0].startswith('**'):
                    item = kwargs.pop(attr[0][2:])
                    attr = attr[1:]
                else:
                    item = self
                for subattr in attr:
                    item = getattr(item, subattr)
                params[param] = item
            elif callable(attr):
                params[param] = attr(self)
            else:
                params[param] = getattr(self, attr)
        if _external is not None:
            params['_external'] = _external
        params.update(kwargs)  # Let kwargs override params

        # url_for from flask
        return url_for(endpoint, **params)