Skip to main content

Simplate

Python Simple Object-Based String Templating

Usage

From formatted strings create re-usable template objects and implementation objects. The Simplate class (Simplate.Simplate) allows you to dynamically create new Template classes with the string you initialize with, and (optionally) a title for the template which becomes the name of your new class.

import Simplate

mySimpleTemplate = Simplate.Simplate( "Hello {friend} how's your {pet}?", title="FriendlyLetter" )
print mySimpleTemplate.ImplementationClass
<class 'Simplate.Simplate.FriendlyLetter'>
newLetterToJohn = mySimpleTemplate.implement()
type(newLetterToJohn)
<class 'Simplate.Simplate.FriendlyLetter'>
newLetterToJohn.friend = "John"
newLetterToJohn.pet = "cute puppy"
str(newLetterToJohn)
"Hello John how's your cute puppy?"

Every call to Simplate.implement() will return a new instance of the dynamically-created template class, and the parameters on the template string become the instance variables on the new instances of this new template class, while the template itself is a shared class variable amongst all instances of this template.

An optional third argument when initializing a Simplate is "defaults", which is what the default values are for the instance variables of the template object. By default, defaults is an empty string.

Examples

import Simplate
emailString = "Dear {name}, thank you for your {item}, unfortunately its sold, sincerely {author}."
emailTemplate = Simplate.Simplate(emailString, "EmailToCustomer")
emailToBob = emailTemplate.implement()
emailToBob.author = "Kyle Kimery"
emailToBob.name = "Bob"
emailToBob.item = "Baseball Merchandise"
print emailToBob
Dear Bob, thank you for your inquiry regarding Baseball Merchandise, I regret to inform you that it's gone, sincerely Kyle Kimery.

Release files for Simplate 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Simplate 1.0.2
File Size Uploaded
Simplate-1.0.2.tar.gz 2.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Simplate 1.0.2
File Interpreter ABI Platform
Simplate-1.0.2-py2-none-any.whl Python 2 none any Details

Total release size: 5.7 kB

Release files / Simplate-1.0.2.tar.gz

Download URL Simplate-1.0.2.tar.gz
Size 2.2 kB
Tags Source
SHA-256 checksum
How to use checksums
34d3c5aebefef17d9c5344140c43bfda5b76e7a41236ab19624b3dfe47f3d990
BLAKE2b-256 checksum
How to use checksums
8e0e30187dacdc674e1f618cf7f180f650f9c751dd25f609466485231a86a3d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

Release files / Simplate-1.0.2-py2-none-any.whl

Download URL Simplate-1.0.2-py2-none-any.whl
Size 3.5 kB
Tags Python 2
SHA-256 checksum
How to use checksums
2b90bae1ca598b26316c36bd3ded89a0fd31cd52cc5aaf446b3fa64e781165e1
BLAKE2b-256 checksum
How to use checksums
7e4dc8b4a9893e1b687743280856e7c3d645b0f98c1a8b44a9c8422eb43259fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.16

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page