Skip to main content

Provides method for dynamically injecting variables into a document and/or HTML like object

Project description

Document argument injector

Provides a simple helper method

Argument(s):

  • document (str) the document loaded as a string
  • params (dict) key,value == match,replacement
  • encapsulation (tuple) variable encapsulation ('leftisde', 'rightside')

Returns the provided document with injected parameters

Usage

from injector import injector

document: str
with open('profile.html', 'r') as file:
    document = file.read()

payload: dict = {
    'user.firstName': 'John',
    'user.lastName': 'Smith',
    'user.email': 'jsmith@example.com',
    'user.phone': '+555111444'
    'user.postcode': '1234 Town',
    'user.address': '12 Street'
}

injector(
    document=document,
    params=params,
    encapsulation=('{', '}')
)

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

document-variable-injector-0.1.2.tar.gz (14.1 kB view hashes)

Uploaded Source

Built Distribution

document_variable_injector-0.1.2-py3-none-any.whl (14.4 kB view hashes)

Uploaded Python 3

Supported by

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