Render e-mail templates to HTML and text
771576
function render (template, locals, callback) {
  var engineExt =
  engineName.charAt(0) === '.' ? engineName : ('.' + engineName)
  var tmplPath = path.join(templatesDir, template + engineExt)
  var origTmplPath = path.join(origTemplatesDir, template + engineExt)

  function renderToText (html) {
    var text = htmlToText.fromString(html, {
      wordwrap: 72 // A little less than 80 characters per line is the de-facto
    // standard for e-mails to allow for some room for quoting
    // and e-mail client UI elements (e.g. scrollbar)
    })

    callback(null, html, text)
  }

  engine(tmplPath, locals)
    .then(renderToText)
    .catch(function () {
      engine(origTmplPath, locals)
        .then(renderToText)
        .catch(function (err) {
          callback(err)
        })
    })
}
936591
def render_or_send(func, message):
    """"""
    if request.endpoint != func.func_name:
        mail.send(message)

    if (current_user.is_authenticated() and current_user.superuser):
        return render_template('debug_email.html', message=message)
282844
function(el, template, context, opts) {
      opts = opts || {};
      if (_.isString(template)) {
        opts.newHTML = template;
      }
      templateRenderer.render(el, template, context, opts);
    }
795962
def render_text(text, preformatted=False):
    
    builder = HtmlBuilder()
    builder._render_text(text, preformatted=preformatted)
    return builder._to_html()
829456
def send_template_email(recipients, title_template, body_template, context, language):
    """"""

    send_emails = getattr(settings, 'SEND_PLANS_EMAILS', True)
    if not send_emails:
        return

    site_name = getattr(settings, 'SITE_NAME', 'Please define settings.SITE_NAME')
    domain = getattr(settings, 'SITE_URL', None)

    if domain is None:
        try:
            Site = apps.get_model('sites', 'Site')
            current_site = Site.objects.get_current()
            site_name = current_site.name
            domain = current_site.domain
        except LookupError:
            pass

    context.update({'site_name': site_name, 'site_domain': domain})

    if language is not None:
        translation.activate(language)

    mail_title_template = loader.get_template(title_template)
    mail_body_template = loader.get_template(body_template)
    title = mail_title_template.render(context)
    body = mail_body_template.render(context)

    try:
        email_from = getattr(settings, 'DEFAULT_FROM_EMAIL')
    except AttributeError:
        raise ImproperlyConfigured('DEFAULT_FROM_EMAIL setting needed for sending e-mails')

    mail.send_mail(title, body, email_from, recipients)

    if language is not None:
        translation.deactivate()

    email_logger.info(u"Email (%s) sent to %s\nTitle: %s\n%s\n\n" % (language, recipients, title, body))
1177026
def EmailTemplate(
        self,
        TemplateId,
        TemplateModel,
        From,
        To,
        TemplateAlias=None,
        Cc=None,
        Bcc=None,
        Subject=None,
        Tag=None,
        ReplyTo=None,
        Headers=None,
        TrackOpens=None,
        TrackLinks="None",
        Attachments=None,
        InlineCss=True,
    ):
        
        return EmailTemplate(
            manager=self,
            TemplateId=TemplateId,
            TemplateAlias=TemplateAlias,
            TemplateModel=TemplateModel,
            From=From,
            To=To,
            Cc=Cc,
            Bcc=Bcc,
            Subject=Subject,
            Tag=Tag,
            ReplyTo=ReplyTo,
            Headers=Headers,
            TrackOpens=TrackOpens,
            TrackLinks=TrackLinks,
            Attachments=Attachments,
            InlineCss=InlineCss,
        )
489233
def send_templated_mail(tpl, subject, context, to=getattr(settings, 'MIDNIGHT_MAIN_ADMIN_EMAIL', 'admin@example.com')):
    
    msg_html = render_to_string(tpl, {'context': context})

    send_mail(subject, '', getattr(settings, 'MIDNIGHT_MAIN_MAIL_FROM', 'admin@example.com'),  [to], html_message=msg_html,)
407293
function html(strings, ...values) {
  let template = templateCache.get(strings);

  if (template === undefined) {
    template = new Template(strings, defaultTemplateProcessor);
    templateCache.set(strings, template);
  }

  return templateResult(template, values);
}
368754
private static String templateToHtml( Template t){
		if( t == null ) {
			return "null";
		}

		StringBuilder result = new StringBuilder();

		result.append(
			"<table class=\"Template\">\n" +
			"<tr><th class=\"Template\">Template</th></tr>\n"+
			"<tr><td class=\"Template\">" +
			"Name: \""+convertTags( t.getName() )+"\"<br>"+
			"</td></tr>\n");

		if( t.getParameters().size() != 0 ){
			result.append("<tr><td class=\"Template\">");
			for( String parameter: t.getParameters() ) {
				result.append("Parameter: \""+convertTags( parameter )+"\"<br>");
			}
			result.append("</td></tr>\n");
		}

		result.append("</table>" );

		return result.toString();
	}
263283
def _render_html(self, libraries):
        """"""

        title = self.options.get("title", "Keyword Documentation")
        date = time.strftime("%A %B %d, %I:%M %p")
        cci_version = cumulusci.__version__

        stylesheet_path = os.path.join(os.path.dirname(__file__), "stylesheet.css")
        with open(stylesheet_path) as f:
            stylesheet = f.read()

        jinjaenv = jinja2.Environment(
            loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), autoescape=False
        )
        jinjaenv.filters["robot_html"] = robot.utils.html_format
        template = jinjaenv.get_template("template.html")
        return template.render(
            libraries=libraries,
            title=title,
            cci_version=cci_version,
            stylesheet=stylesheet,
            date=date,
        )
157780
def displayhtml(public_key,
                attrs,
                use_ssl=False,
                error=None):
    """"""

    error_param = ''
    if error:
        error_param = '&error=%s' % error

    if use_ssl:
        server = API_SSL_SERVER
    else:
        server = API_SERVER

    if 'lang' not in attrs:
        attrs['lang'] = get_language()[:2]

    return render_to_string(
        WIDGET_TEMPLATE,
        {'api_server': server,
         'public_key': public_key,
         'error_param': error_param,
         'lang': attrs['lang'],
         'options': mark_safe(json.dumps(attrs, indent=2))
         })
399586
function renderTemplate(template, context) {
    var esc = $(document.createElement('div'));

    function handle(ph, escape) {
      var cur = context;
      $.each(ph.split('.'), function() {
        cur = cur[this];
      });
      return escape ? esc.text(cur || "").html() : cur;
    }

    return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
      return handle(arguments[2], arguments[1] == '%' ? true : false);
    });
  }
1290235
function render_template(type, object) {
  try {
    return new EJS({text: __templates[type]}).render(object);
  } catch (e) {
    //console.error(e);
    return "";
  }
}
1369411
def render(template, dest, **kwargs):
    '''
    '''

    dest_dir = dirname(dest)
    if dest_dir and not exists(dest_dir):
        makedirs(dest_dir)

    template = environment.get_template(template)
    text = template.render(**kwargs)

    f = open(dest, 'wb')
    f.write(text.encode('utf-8'))
    f.close()
584944
function renderTemplate(template, context) {
			try {
				var func = _.template(template.template);
				return func(context);
			}
			catch (e) {
				grunt.fail.fatal('Error while rendering template ' + template.filename + ': ' + e.message);
			}
		}
375460
function toHtml()
    {
        $e = $this->e;

        try {
            $renderer = new RendererPhp();
            return $renderer->capture(
                __DIR__ . '/../.error.page.php'
                , array('exception' => $e)
            );
        } catch(\Exception $ve) {
            ## throw exception if can't render template
            throw $e;
        }
    }
21721
function () {
    
    var textTemplate = require('./templates/fields/text.html');
    var textareaTemplate = require('./templates/fields/textarea.html');
    var selectTemplate = require('./templates/fields/select.html');
    var checkboxTemplate = require('./templates/fields/checkbox.html');

    var fieldsTarget = []
    $.each(getConfig().customer_fields, function(key, field) {
      var tmpl = textTemplate
      if (field.format === 'textarea') tmpl = textareaTemplate
      if (field.format === 'select') tmpl = selectTemplate
      if (field.format === 'checkbox') tmpl = checkboxTemplate
      if (!field.format) field.format = 'text'
      if (key === 'email') field.format = 'email'
      var data = $.extend({
        key: key,
        arrowDownIcon: require('!svg-inline!./assets/arrow-down-icon.svg')
      }, field)
      var fieldTarget = $(tmpl.render(data))
      fieldsTarget.push(fieldTarget)
    })

    return fieldsTarget
  }