purcell / airspeed

A lightweight Python template engine compatible with Velocity, used in OpenStack
Other
91 stars 37 forks source link

Missing support for trim method. #58

Open rayniel95 opened 2 years ago

rayniel95 commented 2 years ago

I do not sure if this is a bug or a feature (according to https://github.com/purcell/airspeed/issues/47#issuecomment-638552958). But if I execute:

import airspeed

t = airspeed.Template("""
#set($some="      some  ")
$some.trim()
$some.strip()
""")
people = [{'name': 'Bill', 'age': 100}, {'name': 'Bob', 'age': 90}, {'name': 'Mark', 'age': 25}]
print(t.merge(locals()))

the output is:


$some.trim()
some

so, for some reason the trim method used to remove white spaces in Java need to be changed to its Python equivalent.

purcell commented 2 years ago

There are some extra string methods already, see here — if you'd like to submit a PR with a couple of little tests, I'd be happy to incorporate it.