Skip to main content

command line jinja2 template (yet another j2cli)

Project description

https://travis-ci.org/podhmo/kamidana.svg?branch=master

example

$ kamidana ../examples/readme/nginx.jinja2 --data ../examples/readme/data.json
server {
  listen 80;
  server_name localhost;

  root /var/www/project;
  index index.htm;

  access_log /var/log/nginx/http.access.log combined;
  error_log  /var/log/nginx/http.error.log;
}

nginx.jinja2

server {
  listen 80;
  server_name {{ nginx.hostname }};

  root {{ nginx.webroot }};
  index index.htm;

  access_log {{ nginx.logdir }}/http.access.log combined;
  error_log  {{ nginx.logdir }}/http.error.log;
}

data.json

{
  "nginx": {
    "hostname": "localhost",
    "webroot": "/var/www/project",
    "logdir": "/var/log/nginx"
  }
}

example2 (–additionals)

$ kamidana --additionals=../examples/readme2/additionals.py --data=../examples/readme2/data.yaml ../examples/readme2/hello.jinja2
  bye, world!!

hello.jinja2

{% if 19 is night %}
  {{night}}, {{name|surprised}}
{% else %}
  {{daytime}}, {{name|surprised}}
{% endif %}

additionals.py

from kamidana import (
    as_filter,
    as_globals_generator,
    as_test,
)


@as_filter
def surprised(v):
    return "{}!!".format(v)


@as_globals_generator
def generate_globals():
    return {"daytime": "hello", "night": "bye"}


@as_test
def night(hour):
    return 19 <= hour or hour < 3

data.yaml

name: world

0.5.0

  • new kamidana-batch command

  • changing addtionals.reader’s current working directory path

0.4.1

  • fix bug (multi -a option)

0.4.0

  • add kamidana.additionals.reader

0.3.0

  • add –extension option

  • add –dump-context option

0.2.1

  • rename Loader to TemplateLoader

0.2.0

  • –loader option is added

  • interfaces are defined

0.1.0

  • first release

Project details


Download files

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

Source Distribution

kamidana-0.5.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kamidana-0.5.1-py2.py3-none-any.whl (9.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file kamidana-0.5.1.tar.gz.

File metadata

  • Download URL: kamidana-0.5.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for kamidana-0.5.1.tar.gz
Algorithm Hash digest
SHA256 4f712833e038e5bc715a31dd28dc0b21d7bd0876b2b6b6e4d3865a85618b4036
MD5 792bb14ce194b7ca31d38dc2f18b7796
BLAKE2b-256 a01afbbb11333ef3cf682bf2ab3a04acc4f54ea4cc8459b6ba3f2cce250a9fbc

See more details on using hashes here.

File details

Details for the file kamidana-0.5.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for kamidana-0.5.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d3b31dbf343770a540ba49c5772e08b8cd2df5c0541e23be22debe725c3ac2c3
MD5 5c590742c268d862283f429270e30b27
BLAKE2b-256 0f416eeee6514012518d6485c98f57d078f1eb25961bbe9af4ff8e07ca362164

See more details on using hashes here.

Supported by

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