document-variable-injector

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


License
CNRI-Python-GPL-Compatible
Install
pip install document-variable-injector==0.1.2

Documentation

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=('{', '}')
)