예제 #1
0
파일: addressable.py 프로젝트: sandeez/lino
    def get_address_html(self, *args, **kwargs):
        """Returns the full postal address a a string containing html
        markup of style::
        
            <p>line1<br/>line2...</p>

        This returns always exactly one paragraph, even if the address
        is empty (in which case the paragraph is empty):

        >>> print(TestAddress().get_address_html())
        <p />

        Optional attributes for the enclosing `<p>` tag can be
        specified as keyword arguments. Example:

        >>> addr = TestAddress('line1', 'line2')
        >>> print(addr.get_address_html(class_="Recipient"))
        <p class="Recipient">line1<br />line2</p>
          
        If `min_height` is specified, makes sure that the string
        contains at least that many lines. Adds as many empty lines
        (``<br/>``) as needed.  This is useful in a template which
        wants to get a given height for every address.

        >>> print(addr.get_address_html(min_height=5))
        <p>line1<br />line2<br /><br /><br /></p>

        Any arguments are forwarded to :meth:`lines2p
        <lino.utils.xmlgen.html.lines2p>` which is used to pack the address
        lines into a paragraph (see there for more examples).

        """
        lines = list(self.get_address_lines())
        return E.tostring(lines2p(lines, *args, **kwargs))
예제 #2
0
    def get_address_html(self, *args, **kwargs):
        """Returns the full postal address a a string containing html
        markup of style::
        
            <p>line1<br/>line2...</p>

        This returns always exactly one paragraph, even if the address
        is empty (in which case the paragraph is empty):

        >>> print(TestAddress().get_address_html())
        <p />

        Optional attributes for the enclosing `<p>` tag can be
        specified as keyword arguments. Example:

        >>> addr = TestAddress('line1', 'line2')
        >>> print(addr.get_address_html(class_="Recipient"))
        <p class="Recipient">line1<br />line2</p>
          
        If `min_height` is specified, makes sure that the string
        contains at least that many lines. Adds as many empty lines
        (``<br/>``) as needed.  This is useful in a template which
        wants to get a given height for every address.

        >>> print(addr.get_address_html(min_height=5))
        <p>line1<br />line2<br /><br /><br /></p>

        Any arguments are forwarded to :meth:`lines2p
        <lino.utils.xmlgen.html.lines2p>` which is used to pack the address
        lines into a paragraph (see there for more examples).

        """
        lines = list(self.get_address_lines())
        return E.tostring(lines2p(lines, *args, **kwargs))
예제 #3
0
파일: mixins.py 프로젝트: TonisPiip/xl
 def get_address_html(self, *args, **kwargs):
     """
     Return the address of the :attr:`recipient` of this object.
     See
     :meth:`Addressable.get_address_html
     <lino.utils.addressable.Addressable.get_address_html>`.
     """
     rec = self.get_recipient()
     if rec is None:
         return E.tostring(lines2p([], *args, **kwargs))
     return rec.get_address_html(*args, **kwargs)
예제 #4
0
파일: mixins.py 프로젝트: sandeez/lino
 def get_address_html(self, *args, **kwargs):
     """
     Return the address of the :attr:`recipient` of this object.
     See
     :meth:`Addressable.get_address_html
     <lino.utils.addressable.Addressable.get_address_html>`.
     """
     rec = self.get_recipient()
     if rec is None:
         return E.tostring(lines2p([], *args, **kwargs))
     return rec.get_address_html(*args, **kwargs)