Skip to main content

snippet to merge html/css files

Project description

This is a simple example package to combine html/css files. Image of Yaktocat

Quick start

from html_css_gen import template
payload = {'1': 'file_A',
           '2': 'file_B',
           '3': 'file_C'
           ...
           ...
           ...
         }
emailobj=template.init_template(**payload)
output=emailobj.combine_element()
print(output)

combine_element()

Description

Combine all the element in the email object

Return

A combined html string output

Attention

This is compulsory to be called upon init (for now)


add_parent_html(change_data,]html_tags)

Description

Add a parent tag to the combined html file
  • change_data - the html file variable in str to manipulate
  • html_tags - [[start_tag, end_tag]

Return

A combined html file with a new wrapper tag


add_customised_css(change_data, css_input)

Description

Add on universal css after the html file is created. Ideal for adding code relating to the combined output. The additional css string will be appended at the bottom of the css output

  • change_data - the html file variable in str to manipulate
  • css_input- the customised css snippet you wish to append to your current css

Return

A combined html string output with the customised css


populate(change_data, **payload,)

Description

Substitute the values you wish to replace in the html file

  • change_data - the html file variable in str to manipulate
  • **payload - a dictionary with the key being the label in the html file in which you wish the value to be replaced and the value being the data to replace with

Additional Info

  1. Insert {variable name} in the parts of html files which you wishes to have the value replaced

  2. Call the method with a dictionary payload that has the variable name inserted in the html as the key and the value as the value you wish to replace with


export(filename, export_data)

Description

Export the combined file into the desired location

  1. filename - refers to the path in which the file is to be exported
  2. export_data - being the html string file you wish to export, output of the method above

Return None


Full working example

from html_css_gen import template

payload = {'1': 'fileA',
           '2': 'fileB',
           '3': 'fileC'
           }
emailobj=template.init_template(**payload)
template = email_obj.combine_element()
customised_css = '''@media screen and (min-width: 600px) {
                    body {
                        width: 600px; !important
                        }
                    }'''
template_css = email_obj.add_customised_css(
    change_data=template, css_input=customised_css)
template_html = email_obj.add_parent_html(change_data=template_css,
                                          html_tags=[['<div class="sudo">', '</div>']])
final_data = email_obj.populate(template_html,**{'fieldA': 'valueA', 'fieldB': 'valueB'})
email_obj.export(filename='output/unread_email', export_data=final_data)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html_css_gen-2.2.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

html_css_gen-2.2.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file html_css_gen-2.2.1.tar.gz.

File metadata

  • Download URL: html_css_gen-2.2.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for html_css_gen-2.2.1.tar.gz
Algorithm Hash digest
SHA256 76cd5893f88b7b86fc5c4be4ef30de936f32db434cc45bac1d75c4af911e8c06
MD5 4453bc8f52dc36282c3e9529762e5515
BLAKE2b-256 a44e327b2fec15ee7d37143aa3375396960f06d345ff5544e23a6b21f5f7655f

See more details on using hashes here.

File details

Details for the file html_css_gen-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: html_css_gen-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for html_css_gen-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0aca6d144d66c7b3d13f755598d7a1dd6fb5cccb7409d7d924f6b1c527eaa000
MD5 4059976d7d0294adfac25524df9d868f
BLAKE2b-256 6bdf1608a21450be0bca03e96cb6262c68c5e90be16a85b5a6149b67aa8e4998

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page