{"id":15042473,"url":"https://github.com/ekiim/jinjasimplecli","last_synced_at":"2025-07-22T19:04:42.043Z","repository":{"id":62572424,"uuid":"191002042","full_name":"ekiim/jinjasimplecli","owner":"ekiim","description":"A way to use jinja2 templates with *sh scripts.","archived":false,"fork":false,"pushed_at":"2019-06-11T09:58:10.000Z","size":17,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-01T00:05:04.665Z","etag":null,"topics":["argparse","bash","bash-script","cli","jinja2","template","template-engine"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ekiim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-09T12:11:14.000Z","updated_at":"2025-01-07T05:28:52.000Z","dependencies_parsed_at":"2022-11-03T18:26:58.955Z","dependency_job_id":null,"html_url":"https://github.com/ekiim/jinjasimplecli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ekiim/jinjasimplecli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekiim%2Fjinjasimplecli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekiim%2Fjinjasimplecli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekiim%2Fjinjasimplecli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekiim%2Fjinjasimplecli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ekiim","download_url":"https://codeload.github.com/ekiim/jinjasimplecli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekiim%2Fjinjasimplecli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266554205,"owners_count":23947287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argparse","bash","bash-script","cli","jinja2","template","template-engine"],"created_at":"2024-09-24T20:47:21.811Z","updated_at":"2025-07-22T19:04:42.010Z","avatar_url":"https://github.com/ekiim.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jinja Simple CLI\n\nThis project offers a way to easily compose templates directly from the \ncommand line, ideal to use in junction with other cli utilities.\n\nYou could check the examples under the `examples` directory and check the\t\nBy running `jinja-cli --help` on your terminal, you'll get all the basic functioning for the tool.\n\n\n## Basics\n\nIf you know [Jinja][jinja], you will get how this works easily.\n\n- `INPUT` or _template_, is the text stream or file that you are attempting to render _by default stdin_.\n- `DATA` or _json-data_, is the text stream or file that contains the data used in the template and it's dependencies, _by default is an empty json_.\n- `ROOT` or _template-directory_, is the search path for jinja's `FileSystemLoader`.\n- `CONFIG` or _extensions-file_, is a python file that contains functions that will be avalible to call from the templates, could be filters. \n- `OUTPUT` or `output`, is where to write the rendered template, _by default is stdout_.\n\n__Remark__: This is more related to `*sh` scripting than this tool, but notice that we mention streams, so we could run the following commands and they would be equivalent in output.\n\n```\ncat examples/templates/users.htm | jinja-cli -j examples/data/users.json\ncat examples/data/users.json | jinja-cli -j - -i examples/templates/users.htm\njinja-cli -i examples/templates/users.htm -j examples/data/users.json\njinja-cli -i \u003c(cat examples/templates/users.htm) -j \u003c(cat examples/data/users.json)\n```\n\nThis is because the argument parsing for the input template and json data, was thinked in a way that you send any of does two as streams so we could use and compose with other cli tools.\n\n\n## Examples\n\nAll the examples could be reproduced with the files in the `examples` directory.\n\n### Curl in to a template\n\nUsing the data variables you could fill templates pulling data from any kind of source, and insert it using standard input\n\n```\n$ curl https://xkcd.com/2/info.0.json 2\u003e /dev/null | jinja-cli -i examples/templates/xkcd.htm -j -\n\u003carticle\u003e\n    \u003ch2\u003ePetit Trees (sketch)\u003c/h2\u003e\n    \u003cimg src=\"https://imgs.xkcd.com/comics/tree_cropped_(1).jpg\"/\u003e\n    \u003cp\u003e'Petit' being a reference to Le Petit Prince, which I only thought about halfway through the sketch\u003c/p\u003e\n\u003c/article\u003e\n```\n\n### Using Jinja Filters\n\nYou could also use custom functions and call them as filters from your `config` file, eg.\n\n```python3\n\n# fragment of examples/extensions.py\nimport jinjasimplecli.extensions as je\n\n@je.filter('issue')\ndef hello_world(issue_number):\n    url = f\"https://api.github.com/repos/ekiim/jinjasimplecli/issues/{issue_number}\"\n    data = requests.get(url).json()\n    return f\"Issue - {data['number']} - {data['title']}\"\n```\n\nSo now running `$ echo \"{{ 1|issue }}\" | jinja-cli -c examples/extensions.py` we get \n`Issue - 1 - Merge Guide and Readme`. \n\n### Jinja other features\n\nWhen using template inheritance or referencing another template to import or include, \nyou should make reference to it, considering the `ROOT` path you provided.\n\n\n## License\n\nJinja Simple CLI is licensed under the [BSD 3-Clause license][license].\n\n\n[jinja]: http://jinja.pocoo.org/docs/2.10/api/\n[license]: blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekiim%2Fjinjasimplecli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fekiim%2Fjinjasimplecli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekiim%2Fjinjasimplecli/lists"}