Metadata-Version: 2.1
Name: bs4tag
Version: 0.1.0
Summary: Generate HTML or XML in a pythonic way. Pure python alternative to web template engines. Based on BeautifulSoup parser. Can fill HTML forms with default values and error messages.
Home-page: https://www.yattag.org
Author: ceprio
Author-email: c.pypi@zone-c4.com
License: UNKNOWN
Keywords: html,template,templating,xml,document,form,rendering,beautifulsoup
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.2.0
License-File: LICENSE


This library is based on the sources and definitions of yattag with the fondamental difference that BeautifulSoup is used as the html renderer.

Differences between bs4tag and yattag
-------------------------------------

*** At this time, only SimpleDoc has been converted, Doc class is work in progress. ***

- No support for custom indentation (indent)
- stag_end option is not available
- The SimpleDoc/Doc object contains a BeautifulSoup intance in the soup attribute
- asis() and ttls() functions added to SimpleDoc


( tutorial for both libraries: yattag.org_ and BS4_)

Basic example
-------------

Nested html tags, no need to close tags, same as yattag.

.. code:: python

    from bs4tag import Doc

    doc, tag, text = Doc().tagtext()

    with tag('html'):
        with tag('body', id = 'hello'):
            with tag('h1'):
                text('Hello world!')

    print(doc.getvalue())

With BeautifulSoup added functionalities
----------------------------------------

Insert bs4tag document into a BeautifulSoup instance.

.. code:: python

    def body_text():
        doc, tag, text = SimpleDoc().tagtext()
        with tag('h1'):
            text('Hello world!')
        return doc.soup
    
    
    doc, tag, text = SimpleDoc().tagtext()
    
    with tag('html'):
        with tag('body', id='hello'):
            pass
    
    doc.soup.find(id='hello').append(body_text())
    
    print(doc.getvalue())
    # <html><body id="hello"><h1>Hello world!</h1></body></html>

Installation
------------

pip3 install bs4tag



This library is compatible with the tutorial on yattag.org_

GitHub repo: https://github.com/ceprio/bs4tag
Derived from: https://github.com/leforestier/yattag

.. _yattag.org: https://www.yattag.org
.. _bs4: https://beautiful-soup-4.readthedocs.io/en/latest/


