Send html document to user.

        Args:
        - data: Dict to render template, or string with rendered HTML.
        - template: Name of template to render HTML document with passed data.
490404
def html(self, data=None, template=None):
        
        if data is None:
            data = {}
        if template:
            return render(self.request, template, data)
        return HttpResponse(data)
914733
def send(self, to, language=None, **data):
        
        self.data = data
        self.get_context_data()
        if app_settings['SEND_EMAILS']:
            try:
                if language:
                    mail.send(to, template=self.template, context=self.context_data, language=language)
                else:
                    mail.send(to, template=self.template, context=self.context_data)
            except EmailTemplate.DoesNotExist:
                msg = 'Trying to use a non existent email template {0}'.format(self.template)
                LOGGER.error('Trying to use a non existent email template {0}'.format(self.template))
1270713
public function renderHtml($template=null, $data=null)
    {
        $this->beforeRender($data);
        
        $this->beforeRenderView();
        
        $template = !empty($template) ? $template : $this->getName();
        
        $string = $this->module->getView()->render($template, $this->responseData());
        
        return $this->renderText($string);
    }
1006298
public function sendDataAsHtml($data) {
    $this->disableView();
    if (extension_loaded('xdebug')) {
      ob_start();
      var_dump($data);
      $output = ob_get_clean();
    }
    else {
      $output = sprintf(
          '<pre><code>%s</code></pre>',
          json_encode($data,JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)
      );
    }
    $this->setContent($output);
    $this->send();
  }
378197
def render_to_json(templates, context, request):
    
    html = render_to_string(
        templates,
        context=context,
        request=request
    )
    _json = json.dumps({
        "html": html
    })
    return HttpResponse(_json)
597088
def render_text(self, request, instance, context):
        
        render_template = self.get_render_template(request, instance, email_format='text')
        if not render_template:
            # If there is no TEXT variation, create it by removing the HTML tags.
            base_url = request.build_absolute_uri('/')
            html = self.render_html(request, instance, context)
            return html_to_text(html, base_url)

        instance_context = self.get_context(request, instance, email_format='text', parent_context=context)
        instance_context['email_format'] = 'text'

        text = self.render_to_string(request, render_template, instance_context)
        text = text + ""  # Avoid being a safestring
        if self.render_replace_context_fields:
            text = replace_fields(text, instance_context, autoescape=False)
        return text
1002824
def html(self, data='', py=True):
        

        if py:
            value = self.to_html(data)
        else:
            value = data
        if self.static:
            return str('<span class="value">%s</span>' % safe_str(value))
        else:
            if self.hidden:
                build = Hidden
            else:
                build = self.build
            self._get_http_attrs()
            return str(build(name=self.name, value=value, id=self.id, **self.html_attrs))
1266325
function innerRender(from, template, data, callback) {
    var args, proc, out = '',
        err = '',
        base,
        strData;

    if (arguments.length < 4) {
        callback = data;
        data = {};
    }

    if (!template || template.constructor !== String) {
        return callback(new Error('"template" requires a non-empty string'));
    }

    if ('function' !== typeof callback) {
        throw new Error('"callback" requires a function');
    }

    try {
        //Make sure mock data could be stringified
        strData = JSON.stringify(data);
    } catch (e) {
        return callback(e);
    }

    base = gConfigurations.template_dirs;
    //If no template_dirs defined and is rendering a file,
    //we reset the template_dirs to the dirname of the file,
    //and set template as its basename
    //
    //e.g,
    //
    //django.configure({
    //  template_dirs: null
    // });
    //django.renderFile('test/case/index.html');
    //
    //equals
    //
    //django.configure({
    //  template_dirs: 'test/case'
    // });
    //django.renderFile('index.html')
    //
    //That affects @include tag in Django,
    //see https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#include
    //
    if (('file' === from) && !base) {

        base = path.resolve(path.dirname(template));
        template = path.basename(template);
    } 

    args = (('source' === from) ? [PYTHON] : [PYTHON, base, template]).map(function(item, idx) {
        return idx ? encodeURIComponent(item) : item;
    });

    proc = childProcess.spawn('python', args);
    //We use stdin to pass the mock data to avoid long shell arguments
    proc.stdin.write(('source' === from ? (encodeURIComponent(template) +
        '\n') : '') + strData + '\n'); //For python reading a line.

    proc.stdout.on('data', function(data) {
        //Here we get no string but buffer
        out += data.toString('utf-8');
    });
    proc.stderr.on('data', function(data) {
        err += data.toString('utf-8');
    });
    //What if blocked? We ignored it because this is not for production.
    proc.on('exit', function() {
        if (err) {
            return callback(new Error(err));
        } else {
            return callback(null, out.replace(/\r(?=\r\n)/mg, '')); //A \r will always be prepend to \r\n
        }
    });
}
352918
def serialize(self, data):
        

        super(Serializer, self).serialize(data)

        self.resp.content_type += '; header=present'
        import pprint
        pprint.PrettyPrinter().pprint(data)
796279
function render(data) {
                if (!this._rendered) {
                    if (this.template) {
                        if (data) {
                            this.data = data;
                        }
                        var options = this._options,
                            parentChildren = this._parentChildren,
                            decoder = new Decoder(this.template),
                            template = decoder.render(this.data);
                        if (this.el) {
                            var parent = this.el.parentNode;
                            if (parent) {
                                parent.replaceChild(template.fragment, this.el);
                            }
                            if (this.elGroup && this.elGroup.get(this.el)) {
                                this.elGroup.delete(this.el);
                                this.el = template.fragment;
                                this.elGroup.set(template.fragment, this);
                            }
                        } else {
                            this.el = template.fragment;
                        }

                        this.root = new dom.Element(template.fragment, {
                            name: 'root',
                            data: {}
                        });

                        this.children = applyElement(template.children, options);
                        applyParent(this, parentChildren, this.data);
                        this.bindings = setBinders(this.children, true);

                        if (this.data) {
                            this.applyBinders(this.data, this);
                        }

                        setRoutes(this.children, this.context);
                        addChildren(this, this.root);
                        this.rendered.apply(this, _toConsumableArray(this._arguments));
                        this._rendered = true;
                    } else {
                        var HTMLelement = document.createElement('div');
                        this.root = new dom.Element(HTMLelement, {
                            name: 'root',
                            data: {}
                        });
                        if (this.el) {
                            var _parent = this.el.parentNode;
                            if (_parent) {
                                _parent.replaceChild(HTMLelement, this.el);
                            }
                        }
                        this.el = HTMLelement;
                        this.children = {};
                        addChildren(this, this.root);

                        this.rendered.apply(this, _toConsumableArray(this._arguments));
                        this._rendered = true;
                    }
                }
            }
577978
def send_template_message(self, user_id, template_id, data, form_id, page=None, color=None, emphasis_keyword=None):
        
        tpl_data = optionaldict(
            touser=user_id,
            template_id=template_id,
            page=page,
            form_id=form_id,
            data=data,
            color=color,
            emphasis_keyword=emphasis_keyword,
        )
        return self._post(
            'cgi-bin/message/wxopen/template/send',
            data=tpl_data
        )
1189959
def render_requests_data_to_html(self, data, file_name, context={}):
        """"""
        file_path = os.path.join(self.html_dir, file_name)
        logger.info('Rendering HTML file %s...' % file_path)
        data = format_data(data)
        data.update(context)
        data.update(domain=self.domain)
        with open(file_path, 'w') as fp:
            fp.write(render_template('realtime.html', data))
997748
def send_email(self, template, **kwargs):
        
        user_data = {
            "id": self.id,
            "username": self.username,
            "name": self.name,
            "first_name": self.first_name,
            "last_name": self.last_name,
            "email": self.email
        }
        kwargs.pop("user", None)
        send_mail(to=self.email, template=template, user=user_data, **kwargs)
534838
def render(self, template_name, __data=None, **kw):
        ''''''
        return self.template.render(template_name,
                                    **self._vars(__data, **kw))
817534
def render_to_string(self, template, context=None, def_name=None, subdir='templates'):
        ''''''
        template_adapter = self.get_template_loader(subdir).get_template(template)
        return getattr(template_adapter, 'render')(context=context, request=self.request, def_name=def_name)
495588
function (data, callback) {
            var html = '';
            var self = this;
            var fn = self.fn;
            callback = callback || function (error, ret) {
                html = ret;
            };
            var name = self.config.name;
            if (!name && fn.TPL_NAME) {
                name = fn.TPL_NAME;
            }
            var scope = new Scope(data), buffer = new LinkedBuffer(callback).head;
            renderTpl({
                name: name,
                fn: fn,
                session: {},
                root: self
            }, scope, buffer);
            return html;
        }
228901
def render(self, data, accepted_media_type=None, renderer_context=None):
        
        renderer_context = renderer_context or {}
        callback = self.get_callback(renderer_context)
        json = super(JSONPRenderer, self).render(data, accepted_media_type,
                                                 renderer_context)
        return callback.encode(self.charset) + b'(' + json + b');'