Renders page with etag header for evercookie js script
197145
def ec_etag
      if not cookies[Evercookie.cookie_etag].present?
        render :text => request.headers['If-None-Match'] || '', :status => 304
        return true
      end

      puts "cache value (#{Evercookie.cookie_etag}): #{cookies[Evercookie.cookie_etag]}"

      response.headers["Etag"] = cookies[Evercookie.cookie_etag]
      render text: cookies[Evercookie.cookie_etag]
    end
930727
function servePage(bundle, opts) {
  opts = opts || {};

  if (typeof bundle !== 'function') {
    bundle = bundler.create(bundle, opts);
  }

  return function(req, res, next) {
    var location = makeLocation(req, opts.origin);
    var clientReq = request.createRequestFromLocation(location);
    bundle()
      .then(function(bundle) {
        return evaluatePromise({
          bundle: bundle,
          code: renderComponentToString(clientReq),
          debug: opts.debug,
          location: location
        });
      })
      .then(function(rendered) {
        var init = renderComponent(rendered.request.data);
        var markup = rendered.markup.replace(
          '</head>',
          '<script>' + init + '</script>'
        );
        res.setHeader('Content-type', 'text/html');
        res.statusCode = rendered.isNotFoundErrorHandled ? 404 : 200;
        res.write(markup);
        res.end();
      }, function(err) {
        err.isNotFoundError ? res.send(404) : next(err);
      });
  }
}
1206896
function renderHeader(&$header) {
        global $PAGE;

        $header->_generateId();
        $name = $header->getName();

        $id = empty($name) ? '' : ' id="' . $header->getAttribute('id') . '"';
        if (is_null($header->_text)) {
            $header_html = '';
        } elseif (!empty($name) && isset($this->_templates[$name])) {
            $header_html = str_replace('{header}', $header->toHtml(), $this->_templates[$name]);
        } else {
            $header_html = str_replace('{header}', $header->toHtml(), $this->_headerTemplate);
        }

        if ($this->_fieldsetsOpen > 0) {
            $this->_html .= $this->_closeFieldsetTemplate;
            $this->_fieldsetsOpen--;
        }

        // Define collapsible classes for fieldsets.
        $arialive = '';
        $fieldsetclasses = array('clearfix');
        if (isset($this->_collapsibleElements[$header->getName()])) {
            $fieldsetclasses[] = 'collapsible';
            if ($this->_collapsibleElements[$header->getName()]) {
                $fieldsetclasses[] = 'collapsed';
            }
        }

        if (isset($this->_advancedElements[$name])){
            $fieldsetclasses[] = 'containsadvancedelements';
        }

        $openFieldsetTemplate = str_replace('{id}', $id, $this->_openFieldsetTemplate);
        $openFieldsetTemplate = str_replace('{classes}', join(' ', $fieldsetclasses), $openFieldsetTemplate);

        $this->_html .= $openFieldsetTemplate . $header_html;
        $this->_fieldsetsOpen++;
    }
851438
function codepenTagRender(args) {
  const userId = args[0] === 'anonymous' ? 'anon' : args[0];
  const slugHash = args[1];
  const theme = args[2];
  const defaultTab = args[3] != null ? args[3] : 'result';
  const height = args[4] != null ? args[4] : 300;
  const width = args[5] != null ? args[5] : '100%';
  const src = `//codepen.io/${userId}/embed/${slugHash}?height=${height}&theme-id=${theme}&slug-hash=${slugHash}&default-tab=${defaultTab}`;
  const id = `cp_embed_${slugHash.replace(/\//g, '_')}`

  return `<iframe id=${id} src=${src} scrolling="no" frameborder="no" height="${height}" allowTransparency="true" allowfullscreen="true" class="cp_embed_iframe" style="width: ${width}; overflow: hidden;"></iframe>`;
}
822138
async function render(template) {
	const content = {
		badges: await badges(argv.context),
		usage: ''
	}

	if (argv.usage) {
		content.usage = readFileSync(resolve(argv.usage))
	}

	const page = await remark().use(gap).use(squeeze).process(template(content))
	process.stdout.write(page.toString())
}
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;
}
684561
def render_js_template(self, template_path, element_id, context=None):
        
        context = context or {}
        return u"<script type='text/template' id='{}'>\n{}\n</script>".format(
            element_id,
            self.render_template(template_path, context)
        )
353450
async def _async_render(self, *, url: str, script: str = None, scrolldown, sleep: int, wait: float, reload, content: Optional[str], timeout: Union[float, int], keep_page: bool):
        
        try:
            page = await self.browser.newPage()

            # Wait before rendering the page, to prevent timeouts.
            await asyncio.sleep(wait)

            # Load the given page (GET request, obviously.)
            if reload:
                await page.goto(url, options={'timeout': int(timeout * 1000)})
            else:
                await page.goto(f'data:text/html,{self.html}', options={'timeout': int(timeout * 1000)})

            result = None
            if script:
                result = await page.evaluate(script)

            if scrolldown:
                for _ in range(scrolldown):
                    await page._keyboard.down('PageDown')
                    await asyncio.sleep(sleep)
            else:
                await asyncio.sleep(sleep)

            if scrolldown:
                await page._keyboard.up('PageDown')

            # Return the content of the page, JavaScript evaluated.
            content = await page.content()
            if not keep_page:
                await page.close()
                page = None
            return content, result, page
        except TimeoutError:
            await page.close()
            page = None
            return None
282864
def ec_cache
      if not cookies[Evercookie.cookie_cache].present?
        render :nothing => true, :status => 304
        return true
      end

      puts "cache value (#{Evercookie.cookie_cache}): #{cookies[Evercookie.cookie_cache]}"

      response.headers["Content-Type"] = "text/html"
      response.headers["Last-Modified"] = "Wed, 30 Jun 2010 21:36:48 GMT"
      response.headers["Expires"] = "Tue, 31 Dec 2030 23:30:45 GMT"
      response.headers["Cache-Control"] = "private, max-age=630720000"

      render text: cookies[Evercookie.cookie_cache]
    end
871569
def render_urchin(self, ctx, data):
        
        key = website.APIKey.getKeyForAPI(self.store, website.APIKey.URCHIN)
        if key is None:
            return ''
        return ctx.tag.fillSlots('urchin-key', key.apiKey)
557627
function PageScript(req) {
    var codeList = [], bottomScriptList = [], cacheKey;

    /**
     * Add plugin load code. Called for each configured plugin on page.
     * @param pluginOptions {Object} Plugin options object described in plugin properties
     */
    this.addPluginLoad = function (pluginOptions) {
        var pluginLoadJSCode = "Rocket.Plugin.onLoad(" + JSON.stringify(pluginOptions) + ")";
        codeList.push({modules: PLUGIN_MODULE, code: pluginLoadJSCode});
    };

    /**
     * Method adds the code & required modules
     * @param modules {String} Comma separated list of modules, will be passed to require.js
     * @param code {String} Client script Code
     */
    this.add = function (modules, code) {
        codeList.push({modules: modules, code: code});
    };

    /**
     * Method used to include the code block passed to "BottomScript" mixin
     * @param block {Function} jade mixin function
     * @param opts {Object} locals or opts passed to "BottomScript" mixin
     */
    this.addPageBottomCode = function (block, opts) {
        opts.jade = jadeRuntime;
        var func = new Function(_.keys(opts), "var jade_debug = [{filename: ''}]," +
            " buf = [], jade_indent = [], jade_interp;" +
            "(" + block + ")(); return buf.join('')");

        bottomScriptList.push(func.apply(null, _.values(opts)).replace(/<[\/]{0,1}(script|SCRIPT)[^><]*>/g, "").trim());
    };

    /**
     * Renders the scripts added or included in this object into html
     * @param cb {Function} callback function - arguments - err, html
     */
    this.render = function (cb) {
        //if cache is configured, get cache key
        if (ScriptsCache) {
            var page = req.attrs.page;
            cacheKey ||
            (cacheKey = utils.replaceAll(req.url.replace(/\/$/, ""), "/", "_")+ "__" + page.pageId + "__" + req.session.user.userId);
        }

        /**
         * Function renders html.
         * @param callback {Function} callback function - arguments - err, html
         */
        function renderHTML(callback) {
            async.map(codeList, function (locals, n) {
                locals.req = req;
                ViewHelper.render({
                    cache: true,
                    path: SCRIPT_JADE
                }, locals, n)
            }, function (err, buf) {
                if (!err) {
                    buf = buf || [];
                    buf.splice(0, 0, SCRIPT_START_TAG);
                    buf.push(bottomScriptList.join(""));
                    buf.push(SCRIPT_END_TAG);
                }
                callback(err, buf.join(""));
            });
        }

        if (ScriptsCache) {
            ScriptsCache.wrap(cacheKey, function (callback) {
                renderHTML(callback)
            }, cb);
        }
        else {
            renderHTML(cb);
        }

    }
}
397489
public static function ETag() {
      $Data = array();
      $Data['vanilla-core-'.APPLICATION_VERSION] = TRUE;
      
      $Plugins = Gdn::PluginManager()->EnabledPlugins();
      foreach ($Plugins as $Info) {
         $Data[strtolower("{$Info['Index']}-plugin-{$Info['Version']}")] = TRUE;
      }
//      echo(Gdn_Upload::FormatFileSize(strlen(serialize($Plugins))));
//      decho($Plugins);
      
      $Applications = Gdn::ApplicationManager()->EnabledApplications();
      foreach ($Applications as $Info) {
         $Data[strtolower("{$Info['Index']}-app-{$Info['Version']}")] = TRUE;
      }
      
      $Info = Gdn::ThemeManager()->GetThemeInfo(Gdn::ThemeManager()->CurrentTheme());
      if (!empty($Info)) {
         $Version = GetValue('Version', $Info, 'v0');
         $Data[strtolower("{$Info['Index']}-theme-{$Version}")] = TRUE;

         if (Gdn::Controller()->Theme && Gdn::Controller()->ThemeOptions) {
            $Filenames = GetValueR('Styles.Value', Gdn::Controller()->ThemeOptions);
            $Data[$Filenames] = TRUE;
         }
      }
      
      Gdn::PluginManager()->EventArguments['ETagData'] =& $Data;
      
      $Suffix = '';
      Gdn::PluginManager()->EventArguments['Suffix'] =& $Suffix;
      Gdn::PluginManager()->FireAs('AssetModel')->FireEvent('GenerateETag');
      unset(Gdn::PluginManager()->EventArguments['ETagData']);
      
      ksort($Data);
      $Result = substr(md5(implode(',', array_keys($Data))), 0, 8).$Suffix;
//      decho($Data);
//      die();
      return $Result;
   }
49588
function (str, options, cb) {
    var ECT = this.engine;
    var tmpl = this.cache(options) || this.cache(options, new ECT({ root: { page: str }}));
    tmpl.render('page', options, cb);
  }
1011525
def set_evercookie(key, value)
      session[Evercookie.hash_name_for_set] = {key: key, value: value}
      render inline: "<%= javascript_include_tag 'ec', evercookie_set_path -%>"
    end
908755
def render_core(url_prefix, auth_header, resources):
    """"""
    code = ''
    code += "function(root, init) {\n"
    code += "  var q = init('%(auth_header)s', '%(url_prefix)s');\n" %\
        {'url_prefix': url_prefix, 'auth_header': auth_header}
    code += "  var r = null;\n"
    for key in resources:
        code += "  r = root.%(key)s = {};\n" % {'key': key}
        for action, item in resources[key].items():
            code += "    r.%(action)s = q('%(url)s', '%(method)s');\n" %\
                {'action': action,
                 'url': item['url'],
                 'method': item['method']}
    code += "}"
    return code
682165
public function renderScriptsSettings()
    {
        $this->reloadContent();

        $globalScriptsVars = array('pageScriptsHead', 'pageScriptsBodyStart', 'pageScriptsBodyEnd');
        $hooks = array();

        foreach (Finder::findFiles('@*.latte')->in(APP_DIR . '/templates') as $key => $file) {
            $filename = $file->getFileName();

            foreach ($globalScriptsVars as $key => $var) {
                if (\WebCMS\Helpers\SystemHelper::checkFileContainsStr(APP_DIR . '/templates/' . $filename, $var)) {
                    $hooks[$filename][$var] = true;
                } else {
                    $hooks[$filename][$var] = false;
                }
            }
        }

        $this->template->scriptsHooks = $hooks;
    }
409968
function setHeaders(res, body) {
    res.setHeader("Cache-Control", "public, max-age=0");
    res.setHeader("Content-Type", "text/javascript");
    res.setHeader("ETag", etag(body));
}