Simple Python XML/HTML tag builder

When i working with Django sometime i need to write a raw HTML string that will be rendered such as in template tags, etc. Since i also use another web framework (Yii2) which has a lot of utilities, one of the tools is for generating HTML tags with ease. So sometime i miss that a lot while in this situation.

After search through google i found there are some available XML or HTML tag builder but it seems too complex for just my simple needs. so I tend to create one



This is example how to using it in creating of html table.
from simpletag import SimpleTag as T

rows = []
for x in range(10):
    rows.append(T.tr(
                    T.td('Col1'),
                    T.td('Col2')
                    ,scope='row'
                ))

tbody = T.tbody(*rows)
table = T.table(tbody, klass='table table-striped', style='margin-elft: 1;')
print(table)

Comments

Popular posts from this blog

Menambahkan Library Path Pada Pycharm

Dark ozpy