Save a template.

@param string $template_name
@param array $template_fields
@link http://docs.sailthru.com/api/template
@return array API result
512304
public function saveTemplate($template_name, array $template_fields = [ ]) {
        $data = $template_fields;
        $data['template'] = $template_name;
        return $this->apiPost('template', $data);
    }
304478
protected function _render( $template_name, $attributes ) {
		$path = __DIR__ . '/app/view/' . $template_name . '.php';
		if ( ! file_exists( $path ) ) {
			return;
		}

		// @todo Using getter method
		// @codingStandardsIgnoreStart
		extract( $attributes );
		// @codingStandardsIgnoreEnd
		ob_start();
		include( $path );
		return ob_get_clean();
	}
700155
def template_response(self, template_name, headers={}, **values):
        
        response = make_response(
            self.render_template(template_name, **values))

        for field, value in headers.items():
            response.headers.set(field, value)

        return response
302820
def __getTemplate(template_file_name):
        
        with open(template_file_name) as template_file:
            template_raw = template_file.read()

        template = parse(template_raw)
        return template
566340
protected function validateTemplate($template_file)
    {
        $is_valid = false;

        if (!$template_file instanceof \SplFileInfo) {
            $template_file = new \SplFileInfo($template_file);
        }

        // Is this a routable template?
        if (
            $template_file->isFile() &&
            $template_file->isReadable() &&
            ('html' === $template_file->getExtension())
        ) {
            $is_valid = true;
        }

        return($is_valid);
    }
640499
public static void write(final String templateFilename, final Map<String, Object> data,
            final Writer writer) {
        Template tmpl = null;
        try {
            /*-
             * note that we don't need to cache templates by ourselves since getTemplate() does that internally already
             */
            tmpl = conf.getTemplate(templateFilename);
        } catch (FileNotFoundException e1) {
            String errMsg = "FileNotFoundException: template file '" + templateFilename
                    + "' not found";
            log.error("{}: {}", errMsg, e1.getMessage());
            throw new AwsMockException(errMsg, e1);
        } catch (IOException e) {
            String errMsg = "IOException: failed to getTemplate (filename is " + templateFilename
                    + ")";
            log.error("{}: {}", errMsg, e.getMessage());
            throw new AwsMockException(errMsg, e);
        }

        try {
            tmpl.process(data, writer);
        } catch (TemplateException e) {
            StringBuilder dataDescription = new StringBuilder();

            if (null != data) {
                for (Map.Entry<String, Object> entry : data.entrySet()) {
                    dataDescription.append(entry.getKey() + " - " + entry.getValue()).append('\n');
                }
            }
            String errMsg = "TemplateException: failed to process template '" + templateFilename
                    + "', with data: "
                    + dataDescription.toString()
                    + " The probable cause could be un-matching of key-values for that template. ";
            log.error("{}: {}", errMsg, e.getMessage());
            throw new AwsMockException(errMsg, e);
        } catch (IOException e) {
            String errMsg = "IOException: failed to process template and write to writer. ";
            log.error("{}: {}", errMsg, e.getMessage());
            throw new AwsMockException(errMsg, e);
        }

    }
1063770
def get_template(template_name,fields=None):
    '''
    '''
    template = None
    if not template_name.endswith('.html'):
        template_name = "%s.html" %(template_name)
    here = "%s/cli/app/templates" %(get_installdir())
    template_path = "%s/%s" %(here,template_name)
    if os.path.exists(template_path):
        template = ''.join(read_file(template_path))
    if fields is not None:
        for tag,sub in fields.items():
            template = template.replace(tag,sub)
    return template
556654
public function twigRender ($template_file = null, $render = null, $template_dir_list = [], $options = []) {
		$this->renderSetting();
		$template = $this->twigLoadFileTemplate($template_file, $template_dir_list, $options);
		$render = $this->adjustRender($render);
		return $template->render($render);
	}
1371603
public function previewTemplateWithEmail($template, $send_email) {
        $data = [ ];
        $data['template'] = $template;
        $data['send_email'] = $send_email;

        $result = $this->apiPost('preview', $data);
        return $result;
    }
707573
protected function removeFromTemplate($template, $field) {
		$t = $this->getTemplate($template);
		$f = $this->getField($field);
		$success = $t->fieldgroup->remove($f);
		$t->fieldgroup->save();
		return $success;
	}
135754
public function render($field_name, array $attributes = array())
    {
        $field = $this->field($field_name, $attributes);

        return $field->all();
    }
1354083
public function updateTemplateFiles($template_id, Template $request)
    {
      $params = $request->toUpdateParams();
      $response = $this->rest->post(
        static::TEMPLATE_UPDATE_FILES_PATH . '/' . $template_id,
        $params
      );

      return new Template($response);
    }
76267
public function getTemplateById($template_id)
		{
			$form_data = array(
				'template_id' => $template_id
			);
			$xml = $this->call('gettemplatebyid', $form_data);

			$template = new Template;
			$template
				->setFolderId((int)$xml->folder_id)
				->setTemplateId((int)$xml->template_id)
				->setName((string)$xml->template_name)
				->setSubject((string)$xml->template_subject)
				->setBodyPlain((string)$xml->body_plain)
				->setBodyHtml((string)$xml->body_html)
				->setDescription((string)$xml->template_description);

			return $template;
		}
540408
public function twigLoadFileTemplate ($template_file = null, $template_dir_list = [], $options = []) {
		if (isset($this->textTemplate)) {
			return $this->twigLoadStringTemplate($this->textTemplate, $template_dir_list);
		}

		$twig = $this->twigTemplateSetting(null, $template_dir_list, $options);
		$this->templateDir = $this->templateDir ?: $this->controller;
		$this->template = $this->template ?: $this->action;

		if ($template_file === null) {
			if (!isset($this->templateFile) || $this->templateFile === null) {
				$this->templateFile = PathTrait::CreateFilePath([implode('.', [Strings::ToSnakeCase($this->template), $this->mimeType, 'twig'])]);
			}
			$template_file = $this->templateFile;
		}

		return $twig->loadTemplate($template_file);
	}
284115
def save_config(template, params)
      config_file = File.join(config_dir, "#{template}.yml")
      config = File.read(config_file)

      params.map { |key, value| config = config.gsub(key, value) }

      File.open(config_file, 'w') { |file| file.write(config) }
    end
1184061
public function render(string $template_file = '')
    {
        $this->initEngine();
        $this->initRender();

        return $this->engine->fetch($template_file);
    }
580939
public function serialize(TemplateType $templateType)
    {
        $serialized = [
            'id' => $templateType->getUuid(),
            'name' => $templateType->getName(),
            'placeholders' => $templateType->getPlaceholders(),
            'defaultTemplate' => $templateType->getDefaultTemplate(),
        ];

        return $serialized;
    }