Compile templates

@param  string $type    [description]
@param  string $method  [description]
@param  string $model   [description]
@param  string $element [description]
@return string
973395
protected function render($type = 'list', $method, $model, $element)
    {
        $template = $this->getTemplate($type);

        return $this->mustache->render($template, array(
            'formElements' => $this->getFormElements($type, $element),
            'element'      => $element,
            'formOpen'     => $this->getFormOpen($method, $model)
        ));
    }
1060201
private void compileTemplateString(ComponentExposedTypeGenerator exposedTypeGenerator,
      TemplateParserResult templateParserResult) {
    VueTemplateCompilerResult compilerResult;
    try {
      VueTemplateCompiler vueTemplateCompiler = new VueTemplateCompiler();
      compilerResult = vueTemplateCompiler.compile(templateParserResult.getProcessedTemplate());
    } catch (VueTemplateCompilerException e) {
      e.printStackTrace();
      throw new RuntimeException();
    }

    generateGetRenderFunction(exposedTypeGenerator, compilerResult, templateParserResult);
    generateGetStaticRenderFunctions(exposedTypeGenerator, compilerResult);
  }
795353
protected function fillTemplate($template, Model $model)
    {
        $template = str_replace('{{namespace}}', $model->getBaseNamespace(), $template);
        $template = str_replace('{{class}}', $model->getClassName(), $template);

        $properties = $this->properties($model);
        $usedClasses = $this->extractUsedClasses($properties);
        $template = str_replace('{{properties}}', $properties, $template);

        $parentClass = $model->getParentClass();
        $usedClasses = array_merge($usedClasses, $this->extractUsedClasses($parentClass));
        $template = str_replace('{{parent}}', $parentClass, $template);

        $body = $this->body($model);
        $usedClasses = array_merge($usedClasses, $this->extractUsedClasses($body));
        $template = str_replace('{{body}}', $body, $template);

        $usedClasses = array_unique($usedClasses);
        $usedClassesSection = $this->formatUsedClasses(
            $model->getBaseNamespace(),
            $usedClasses
        );
        $template = str_replace('{{imports}}', $usedClassesSection, $template);

        return $template;
    }
893086
function(element) {
    if (!element.bindings) {
      element.bindings = compile(this, element);
      View.makeInstanceOf(element);
    }

    return element;
  }
122882
public function compile(): void
	{
		// Get teplate contents

		$contents = $this->fileSystem->get($this->template);

		// Compile template

		foreach($this->compileOrder as $method)
		{
			$contents = $this->$method($contents);
		}

		// Store compiled template

		$this->fileSystem->put($this->cachePath . '/' . md5($this->template) . '.php', trim($contents));
	}
363707
protected function compileTemplate($template)
	{
		$template = $this->normalizer->normalizeTemplate($template);

		// Parse the template
		$ir = TemplateParser::parse($template);

		// Serialize the representation to PHP
		$php = $this->serializer->serialize($ir->documentElement);
		if (isset($this->optimizer))
		{
			$php = $this->optimizer->optimize($php);
		}

		return $php;
	}
1366651
protected function fillTemplate($template, Model $model)
    {
        $template = str_replace('{{date}}', Carbon::now()->toRssString(), $template);
        $template = str_replace('{{namespace}}', $model->getBaseNamespace(), $template);
        $template = str_replace('{{parent}}', $model->getParentClass(), $template);
        $template = str_replace('{{properties}}', $this->properties($model), $template);
        $template = str_replace('{{class}}', $model->getClassName(), $template);
        $template = str_replace('{{body}}', $this->body($model), $template);

        return $template;
    }
30907
function render(form, template) {
  const compiledRowTemplate = handlebars.compile(
    '<tr class="form-element">' +
      '<td class="key">{{key}}</td>' +
      '<td class="value">{{value}}</td>' +
    '</tr>');
  const compiledTable = handlebars.compile(
    '<table><tbody>{{{rows}}}</tbody></table>');
  const compiledTemplate = handlebars.compile(template);

  const formElements = form.map(({key, value}) => {
    if (key !== 'File') {
      return compiledRowTemplate({key, value: unescape(value)});
    }

    return null;
  });

  const formData = compiledTable({rows: formElements.join(' ')});

  return compiledTemplate({formData});
}
1021953
public function parseField(PreparseFieldType $field, Element $element)
    {
        $fieldTwig = $field->fieldTwig;
        $columnType = $field->columnType;
        $decimals = $field->decimals;
        $fieldValue = null;

        $elementTemplateName = 'element';

        if (method_exists($element, 'refHandle')) {
            $elementTemplateName = strtolower($element->refHandle());
        }

        // Enable generateTransformsBeforePageLoad always
        $generateTransformsBeforePageLoad = Craft::$app->config->general->generateTransformsBeforePageLoad;
        Craft::$app->config->general->generateTransformsBeforePageLoad = true;

        // save cp template path and set to site templates
        $oldMode = Craft::$app->view->getTemplateMode();
        Craft::$app->view->setTemplateMode(View::TEMPLATE_MODE_SITE);

        // render value from the field template
        try {
            $vars = array_merge(['element' => $element], [$elementTemplateName => $element]);
            $fieldValue = Craft::$app->view->renderString($fieldTwig, $vars);
        } catch (\Exception $e) {
            Craft::error('Couldn’t render value for element with id “'.$element->id.'” and preparse field “'.
                $field->handle.'” ('.$e->getMessage().').', __METHOD__);
        }

        // restore cp template paths
        Craft::$app->view->setTemplateMode($oldMode);

        // set generateTransformsBeforePageLoad back to whatever it was
        Craft::$app->config->general->generateTransformsBeforePageLoad = $generateTransformsBeforePageLoad;

        if (null === $fieldValue) {
            return null;
        }

        if ($columnType === Schema::TYPE_FLOAT || $columnType === Schema::TYPE_INTEGER) {
            if ($decimals > 0) {
                return number_format(trim($fieldValue), $decimals, '.', '');
            }

            return number_format(trim($fieldValue), 0, '.', '');
        }

        return $fieldValue;
    }
186565
public function compile($template, $data = array())
    {
        $compiler = new BladeCompiler($this->files, 'theme');

        // Get blade compiler.
        $parsed = $compiler->compileString($template);

        ob_start() and extract($data, EXTR_SKIP);
        try {
            eval('?>'.$parsed);
        } catch (\Exception $e) {
            ob_end_clean(); throw $e;
        }
        $template = ob_get_contents();
        ob_end_clean();

        return $template;
    }
1032271
public function showElementAction ($elementType, $key)
    {
        try
        {
            $element = $this->elementTypesModel->getElement($key, $elementType);

            if ((null === $element) || $element->isHidden())
            {
                throw new NotFoundHttpException("Element '{$key}' of type '{$elementType}' not found.");
            }

            $templateSuffix = $this->elementTypesModel->isFullPageElementType($elementType) ? "_fullpage" : "";

            return $this->twig->render("@core/show_element{$templateSuffix}.twig", [
                "element" => $element
            ]);
        }
        catch (\InvalidArgumentException $e)
        {
            throw new NotFoundHttpException("Unknown element type '{$elementType}'.", $e);
        }
    }
1334138
function compileTemplate( $tpl, $keyData, $uri, $res, $templatePath, &$extraParameters, &$resourceData )
    {
        $key = $this->cacheKey( $keyData, $res, $templatePath, $extraParameters );
        return eZTemplateCompiler::compileTemplate( $tpl, $key, $resourceData );
    }
432291
public function template($type, $options) {
		if (isset($options[$type])) {
			return $options[$type];
		}
		return isset($options['template']) ? $options['template'] : '';
	}
436870
public static function attachLabel($element, $label, $type = self::LABEL_TOP) {
    Code::value($type, self::LABEL_TOP, self::LABEL_CHECKBOX);

    if ($label != NULL) {
      $element->templateContent->label = fHTML::label($label, $element)
        ->addClass('\Psc\label')
      ;
    
      if ($type == self::LABEL_TOP) {
        $element->templatePrepend('%label%');  // nicht überschreiben sondern prependen
      }
    
      if ($type == self::LABEL_CHECKBOX) {
        $element->template = '%self% %label%';
        $element->templateContent->label->addClass('checkbox-label');
      }
    }
    
    return $element;
  }
1201847
function compileCoffeeTemplate(moduleName, content, quoteChar, indentString, htmlmin) {
        var contentModified = getContent(content, quoteChar, indentString, htmlmin);
        var doubleIndent = indentString + indentString;

        var module = 'angular.module(' + quoteChar + moduleName +
            quoteChar + ', []).run([' + quoteChar + '$templateCache' + quoteChar + ', ($templateCache) ->\n' +
            indentString + '$templateCache.put(' + quoteChar + moduleName + quoteChar + ',\n' + doubleIndent + quoteChar + contentModified +
            quoteChar + ')\n])\n';

        return module;
    }
297952
function $$processDirective(el, scope, directive, type) {
    let template,
        prom;

    // Template parsing
    if (
        directive.hasOwnProperty('templatePath') &&
        directive.templatePath.indexOf('.html') > -1
    ) {
        template = $$templateLoader(directive.templatePath, 'template', 'utf8');
    } else if (directive.hasOwnProperty('template')) {
        template = directive.template;
    }

    if (template) {

        // Setup the template HTML observing the prepend/append properties
        prom = $compile(template)(scope, false).then(function(t) {
            el.html(
                `${directive.prepend === true ? '' : el.html()}${t}` +
                `${directive.prepend !== true ? '' : el.html()}`
            );
        });
    } else {
        prom = new Promise((r) => r());
    }

    // Setup Attrs
    let attr = el[0].attribs || {},
        parsedAttrs = {};
    if (Object.keys(attr).length) {
        for (let key in attr) {
            if (attr[ key ]) {
                parsedAttrs[ $StringUtil.toCamel(key) ] = attr[ key ];
            }
        }
    }

    // Link functionality
    if (
        directive.hasOwnProperty('link') &&
        typeof directive.link === 'function'
    ) {
        prom = prom.then(function() {
            return new Promise(function(resolve) {
                let $response = {};

                // Assign a function that can be called to resolve async
                // behavior in directives
                try {
                    $response = $Injector.get('$response');
                } catch(e) {} finally {
                    $response.done = resolve;
                }

                const link = directive.link.call(
                    scope,
                    scope,
                    type !== 'M' ? el : null,
                    parsedAttrs,
                    resolve
                );

                if (
                    !link ||
                    !link.constructor ||
                    link.constructor.name !== 'Promise'
                ) {
                    resolve(link);
                }
            });
        }).then(function() {
            if (el.attr) {
                for (let key in parsedAttrs) {

                    // Replace all of the element attrs with parsedAttrs
                    if (directive.$names.indexOf(key) === -1) {
                        el.attr($StringUtil.toDash(key), parsedAttrs[ key ]);
                    }
                }
            }
        });
    }

    return prom;
}
473178
function compile(fragments, template) {
  var walker = document.createTreeWalker(template, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT);
  var bindings = [], currentNode, parentNode, previousNode;

  // Reset first node to ensure it isn't a fragment
  walker.nextNode();
  walker.previousNode();

  // find bindings for each node
  do {
    currentNode = walker.currentNode;
    parentNode = currentNode.parentNode;
    bindings.push.apply(bindings, getBindingsForNode(fragments, currentNode, template));

    if (currentNode.parentNode !== parentNode) {
      // currentNode was removed and made a template
      walker.currentNode = previousNode || walker.root;
    } else {
      previousNode = currentNode;
    }
  } while (walker.nextNode());

  return bindings;
}