コード例 #1
0
    def to_html(self,
                sep=None,
                css=True,
                js=True,
                debug=False,
                async_load=False,
                url_for=(lambda url: url),
                **kw):
        if 'async' in kw:
            _logger.warning(
                "Using deprecated argument 'async' in to_html call, use 'async_load' instead."
            )
            async_load = kw['async']
        nodes = self.to_node(css=css,
                             js=js,
                             debug=debug,
                             async_load=async_load)

        if sep is None:
            sep = u'\n            '
        response = []
        for tagName, attributes, content in nodes:
            html = u"<%s " % tagName
            for name, value in attributes.items():
                if value or isinstance(value, string_types):
                    html += u' %s="%s"' % (name, escape(to_text(value)))
            if content is None:
                html += u'/>'
            else:
                html += u'>%s</%s>' % (escape(to_text(content)), tagName)
            response.append(html)

        return sep + sep.join(response)
コード例 #2
0
 def to_html(self):
     tagName, attributes, content = self.to_node()
     html = u"<%s " % tagName
     for name, value in attributes.items():
         if value or isinstance(value, string_types):
             html += u' %s="%s"' % (name, escape(to_text(value)))
     if content is None:
         html += u'/>'
     else:
         html += u'>%s</%s>' % (escape(to_text(content)), tagName)
     return html
コード例 #3
0
 def to_node(self):
     if self.url:
         attr = OrderedDict([
             ["type", "text/css"], ["rel", "stylesheet"],
             ["href", self.html_url],
             ["media",
              escape(to_text(self.media)) if self.media else None]
         ])
         return ("link", attr, None)
     else:
         attr = OrderedDict([[
             "type", "text/css"
         ], ["media",
             escape(to_text(self.media)) if self.media else None]])
         return ("style", attr, self.with_header())
コード例 #4
0
ファイル: contact.py プロジェクト: xAlphaOmega/rg_custom
    def value_to_html(self, value, options):
        if not value.exists():
            return False

        opf = options and options.get('fields') or ["name", "address", "phone", "mobile", "email"]
        value = value.sudo().with_context(show_address=True)
        name_get = value.name_get()[0][1]

        val = {
            'name': name_get.split("\n")[0],
            'address': escape("\n".join(name_get.split("\n")[1:])).strip(),
            'phone': value.phone,
            'mobile': value.mobile,
            'city': value.city,
            'country_id': value.country_id.display_name,
            'website': value.website,
            'email': value.email,
            'status': value.status,
            'fields': opf,
            'object': value,
            'options': options
        }
        return self.env['ir.qweb'].render('base.contact', val)
コード例 #5
0
                self.stylesheets.append(StylesheetAsset(self, url=f['url'], filename=f['filename'], inline=f['content'], media=f['media']))
            elif f['atype'] == 'text/javascript':
                self.javascripts.append(JavascriptAsset(self, url=f['url'], filename=f['filename'], inline=f['content']))

    # depreciated and will remove after v11
    def to_html(self, sep=None, css=True, js=True, debug=False, async=False, url_for=(lambda url: url)):
        nodes = self.to_node(css=css, js=js, debug=debug, async=async)

        if sep is None:
            sep = u'\n            '
        response = []
        for tagName, attributes, content in nodes:
            html = u"<%s " % tagName
            for name, value in attributes.items():
                if value or isinstance(value, string_types):
                    html += u' %s="%s"' % (name, escape(to_text(value)))
            if content is None:
                html += u'/>'
            else:
                html += u'>%s</%s>' % (escape(to_text(content)), tagName)
            response.append(html)

        return sep + sep.join(response)

    def to_node(self, css=True, js=True, debug=False, async=False):
        """
        :returns [(tagName, attributes, content)] if the tag is auto close
        """
        response = []
        if debug == 'assets':
            if css and self.stylesheets: