Skip to main content

kamo is almost subset of mako, maybe

Project description

almost subset of mako. this is a toy package.

don’t use in production!!

# -*- coding:utf-8 -*-
import logging
from kamo import Template
logging.basicConfig(level=logging.DEBUG)


template = Template("""
<%
def decorate(s):
    return "** {} **".format(s)
%>
<%!from datetime import datetime%>

${greeting|decorate}
${name}: this is my first sample! (now: ${datetime.now()})
""")


print(template.render(name="foo", greeting="chears"))
print("----------------------------------------")
print(template.render(name="boo", greeting="chears"))

generated function is such as below.

from datetime import datetime


def render(io, **c):
    write = io.write
    def decorate(s):
        return "** {} **".format(s)

    write(str(decorate(c['greeting'])))
    write('\n')
    write(str(c['name']))
    write(': this is my first sample! (now: ')
    write(str(datetime.now()))
    write(')\n')

lookup template

foo.kamo

${name}: yup

foo.py

from kamo import TemplateManager
tm = TemplateManager(directories=["."])
template = tm.lookup("foo.kamo")    # find template from ["./foo.kamo"]
print(template.render(name="foo"))

Project details


Release history Release notifications | RSS feed

This version

0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kamo-0.0.tar.gz (9.4 kB view details)

Uploaded Source

File details

Details for the file kamo-0.0.tar.gz.

File metadata

  • Download URL: kamo-0.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for kamo-0.0.tar.gz
Algorithm Hash digest
SHA256 9012b4d8c5daaf7cec97a91025e4de51c0e721be37a0fe6043844b2b650da92d
MD5 ded51cdf15c95bf73f931e04207466ce
BLAKE2b-256 a44878d357d251ceef306d5773c01f0c0b2662763ec1cf199d0b1bbedd319aec

See more details on using hashes here.

Supported by

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