Skip to main content

Wempy is a command line tool for parsing embedded python (similar to Ruby’s erb). Wempy’s syntax is pure python with 3 very important differences:

  1. There is no need for indentation

  2. The python keyword ‘pass’ must be used to indicate the end of some satements, blocks, and loops (like if/else, Try/Except, for or while ) depending on context

  3. ‘extend’ and ‘include’ are special keywords used to make templates (which can inherit)

Example

% wempy <<-EOF

{{first_name = 'Tyler'}}

{{last_name = 'Durden'}}

Hello Mr. {{=last_name}} or shall I call you {{=first_name}} instead?

EOF

This generates the following output:

Hello Mr.  Durden  or shall I call you  Tyler  instead?

You can see the python script that is generated & executed by using the -x flag.

% wempy -x <<-EOF

{{first_name = 'Tyler'}}

{{last_name = 'Durden'}}

Hello Mr. {{=last_name}} or shall I call you {{=first_name}} instead?

EOF

Which prints out:

import sys

sys.stdout.write('    ')

first_name = 'Tyler'

sys.stdout.write('\n    ')

last_name = 'Durden'

sys.stdout.write('\n    Hello Mr. ')

sys.stdout.write(last_name)

sys.stdout.write(' or shall I call you ')

sys.stdout.write(first_name)

sys.stdout.write(' instead?\n')

wempy.py shows how to use the wemplate library. But here’s a quick rundown:

>> import wemplate.wemplate

>> text="Hello {{=planet}} !"

>> parser = wemplate.wemplate.TemplateParser(text)

>>

>> print parser.render(planet="World")       #print the rendered template

'Hello World !'

Origin

Wempy is taken directly from Web2py’s template engine. We’ve removed some things like the gluon integration wrapper functions, the response object, and HTML/XML escaping.

The name stands for (W)eb2py’s (Em)bedded (Py)thon

Documentation

There isn’t any for wempy (yet). To understand the caveats of the engine take a look at the Views Basic Syntax section of the web2py manual

I’ll be working on Wempy specific documentation shortly

License

As Web2py is licensed under the LGPL v3 so too is Wempy

Home

More information will soon be available at http://www.wempy.org

Release files for wempy 0.2.1

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

Built distribution (wheel)

Table of built distributions (wheels) for wempy 0.2.1
File Interpreter ABI Platform
wempy-0.2.1-py3-none-any.whl Python 3 none any Details

Release files / wempy-0.2.1-py3-none-any.whl

Download URL wempy-0.2.1-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2fb3067ded877dddc749ca6ec83e3a7d36b04a7d5e07ed74f12feda881cad66
BLAKE2b-256 checksum
How to use checksums
fc7a13cdb4fecfeffc967768a98e313e73e0dfc807b13ff22d7a5b5f704def47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release history Release notifications | RSS feed

This release

0.2.1 This release

1 release file

0.2.0

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

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