[![PyPI version](https://badge.fury.io/py/chevron.svg)](https://badge.fury.io/py/chevron)
[![Build Status](https://travis-ci.org/noahmorrison/chevron.svg?branch=master)](https://travis-ci.org/noahmorrison/chevron)
[![Coverage Status](https://coveralls.io/repos/github/noahmorrison/chevron/badge.svg?branch=master)](https://coveralls.io/github/noahmorrison/chevron?branch=master)
A python implementation of the [mustache templating language](http://mustache.github.io).
Why chevron?
------------
I'm glad you asked!
### chevron is fast ###
Chevron runs in less than half the time of [pystache](http://github.com/defunkt/pystache) (Which is not even up to date on the spec).
And in about 70% the time of [Stache](https://github.com/hyperturtle/Stache) (A 'trimmed' version of mustache, also not spec compliant).
### chevron is pep8 ###
The flake8 command is run by [travis](https://travis-ci.org/noahmorrison/chevron) to ensure consistency.
### chevron is spec compliant ###
Chevron passes all the unittests provided by the [spec](https://github.com/mustache/spec) (in every version listed below).
If you find a test that chevron does not pass, please [report it.](https://github.com/noahmorrison/chevron/issues/new)
### chevron is Python 2 and 3 compatible ###
Python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, and 3.6 are all tested by travis.
USAGE
-----
Commandline usage: (if installed via pypi)
```
usage: chevron [-h] [-v] [-d DATA] [-p PARTIALS_PATH] [-e PARTIALS_EXT]
[-l DEF_LDEL] [-r DEF_RDEL]
template
positional arguments:
template The mustache file
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-d DATA, --data DATA The json data file
-p PARTIALS_PATH, --path PARTIALS_PATH
The directory where your partials reside
-e PARTIALS_EXT, --ext PARTIALS_EXT
The extension for your mustache partials, 'mustache'
by default
-l DEF_LDEL, --left-delimiter DEF_LDEL
The default left delimiter, "{{" by default.
-r DEF_RDEL, --right-delimiter DEF_RDEL
The default right delimiter, "}}" by default.
```
Python usage with strings
```python
import chevron
chevron.render('Hello, {{ mustache }}!', {'mustache': 'World'})
```
Python usage with file
```python
import chevron
with open('file.mustache', 'r') as f:
chevron.render(f, {'mustache': 'World'})
```
Python usage with unpacking
```python
import chevron
args = {
'template': 'Hello, {{ mustache }}!',
'data': {
'mustache': 'World'
}
}
chevron.render(**args)
```
chevron supports partials (via dictionaries)
```python
import chevron
args = {
'template': 'Hello, {{> thing }}!',
'partials_dict': {
'thing': 'World'
}
}
chevron.render(**args)
```
chevron supports partials (via the filesystem)
```python
import chevron
args = {
'template': 'Hello, {{> thing }}!',
# defaults to .
'partials_path': 'partials/',
# defaults to mustache
'partials_ext': 'ms',
}
# ./partials/thing.ms will be read and rendered
chevron.render(**args)
```
chevron supports lambdas
```python
import chevron
def first(text, render):
# return only first occurance of items
result = render(text)
return [ x.strip() for x in result.split(" || ") if x.strip() ][0]
def inject_x(text, render):
# inject data into scope
return render(text, {'x': 'data'})
args = {
'template': 'Hello, {{# first}} {{x}} || {{y}} || {{z}} {{/ first}}! {{# inject_x}} {{x}} {{/ inject_x}}',
'data': {
'y': 'foo',
'z': 'bar',
'first': first,
'inject_x': inject_x
}
}
chevron.render(**args)
```
INSTALL
-------
- with git
```
$ git clone https://github.com/noahmorrison/chevron.git
```
or using submodules
```
$ git submodules add https://github.com/noahmorrison/chevron.git
```
Also available on pypi!
- with pip
```
$ pip install chevron
```
TODO
---
* get popular
* have people complain
* fix those complaints
Raw data
{
"_id": null,
"home_page": "https://github.com/noahmorrison/chevron",
"name": "chevron",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "noah morrison",
"author_email": "noah@morrison.ph",
"download_url": "https://files.pythonhosted.org/packages/15/1f/ca74b65b19798895d63a6e92874162f44233467c9e7c1ed8afd19016ebe9/chevron-0.14.0.tar.gz",
"platform": "",
"description": "[![PyPI version](https://badge.fury.io/py/chevron.svg)](https://badge.fury.io/py/chevron)\n[![Build Status](https://travis-ci.org/noahmorrison/chevron.svg?branch=master)](https://travis-ci.org/noahmorrison/chevron)\n[![Coverage Status](https://coveralls.io/repos/github/noahmorrison/chevron/badge.svg?branch=master)](https://coveralls.io/github/noahmorrison/chevron?branch=master)\n\nA python implementation of the [mustache templating language](http://mustache.github.io).\n\nWhy chevron?\n------------\n\nI'm glad you asked!\n\n### chevron is fast ###\n\nChevron runs in less than half the time of [pystache](http://github.com/defunkt/pystache) (Which is not even up to date on the spec).\nAnd in about 70% the time of [Stache](https://github.com/hyperturtle/Stache) (A 'trimmed' version of mustache, also not spec compliant).\n\n### chevron is pep8 ###\n\nThe flake8 command is run by [travis](https://travis-ci.org/noahmorrison/chevron) to ensure consistency.\n\n### chevron is spec compliant ###\n\nChevron passes all the unittests provided by the [spec](https://github.com/mustache/spec) (in every version listed below).\n\nIf you find a test that chevron does not pass, please [report it.](https://github.com/noahmorrison/chevron/issues/new)\n\n### chevron is Python 2 and 3 compatible ###\n\nPython 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, and 3.6 are all tested by travis.\n\n\n\nUSAGE\n-----\n\nCommandline usage: (if installed via pypi)\n```\nusage: chevron [-h] [-v] [-d DATA] [-p PARTIALS_PATH] [-e PARTIALS_EXT]\n [-l DEF_LDEL] [-r DEF_RDEL]\n template\n\npositional arguments:\n template The mustache file\n\noptional arguments:\n -h, --help show this help message and exit\n -v, --version show program's version number and exit\n -d DATA, --data DATA The json data file\n -p PARTIALS_PATH, --path PARTIALS_PATH\n The directory where your partials reside\n -e PARTIALS_EXT, --ext PARTIALS_EXT\n The extension for your mustache partials, 'mustache'\n by default\n -l DEF_LDEL, --left-delimiter DEF_LDEL\n The default left delimiter, \"{{\" by default.\n -r DEF_RDEL, --right-delimiter DEF_RDEL\n The default right delimiter, \"}}\" by default.\n```\n\nPython usage with strings\n```python\nimport chevron\n\nchevron.render('Hello, {{ mustache }}!', {'mustache': 'World'})\n```\n\nPython usage with file\n```python\nimport chevron\n\nwith open('file.mustache', 'r') as f:\n chevron.render(f, {'mustache': 'World'})\n```\n\nPython usage with unpacking\n```python\nimport chevron\n\nargs = {\n 'template': 'Hello, {{ mustache }}!',\n\n 'data': {\n 'mustache': 'World'\n }\n}\n\nchevron.render(**args)\n```\n\nchevron supports partials (via dictionaries)\n```python\nimport chevron\n\nargs = {\n 'template': 'Hello, {{> thing }}!',\n\n 'partials_dict': {\n 'thing': 'World'\n }\n}\n\nchevron.render(**args)\n```\n\nchevron supports partials (via the filesystem)\n```python\nimport chevron\n\nargs = {\n 'template': 'Hello, {{> thing }}!',\n\n # defaults to .\n 'partials_path': 'partials/',\n\n # defaults to mustache\n 'partials_ext': 'ms',\n}\n\n# ./partials/thing.ms will be read and rendered\nchevron.render(**args)\n```\n\nchevron supports lambdas\n```python\nimport chevron\n\ndef first(text, render):\n # return only first occurance of items\n result = render(text)\n return [ x.strip() for x in result.split(\" || \") if x.strip() ][0]\n\ndef inject_x(text, render):\n # inject data into scope\n return render(text, {'x': 'data'})\n\nargs = {\n 'template': 'Hello, {{# first}} {{x}} || {{y}} || {{z}} {{/ first}}! {{# inject_x}} {{x}} {{/ inject_x}}',\n\n 'data': {\n 'y': 'foo',\n 'z': 'bar',\n 'first': first,\n 'inject_x': inject_x\n }\n}\n\nchevron.render(**args)\n```\n\nINSTALL\n-------\n\n- with git\n```\n$ git clone https://github.com/noahmorrison/chevron.git\n```\n\nor using submodules\n```\n$ git submodules add https://github.com/noahmorrison/chevron.git\n```\n\nAlso available on pypi!\n\n- with pip\n```\n$ pip install chevron\n```\n\n\n\nTODO\n---\n\n* get popular\n* have people complain\n* fix those complaints\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Mustache templating language renderer",
"version": "0.14.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "0d0866d1bf57265bdb22619ca071a4e7",
"sha256": "fbf996a709f8da2e745ef763f482ce2d311aa817d287593a5b990d6d6e4f0443"
},
"downloads": -1,
"filename": "chevron-0.14.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0d0866d1bf57265bdb22619ca071a4e7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 11595,
"upload_time": "2021-01-02T22:47:57",
"upload_time_iso_8601": "2021-01-02T22:47:57.847122Z",
"url": "https://files.pythonhosted.org/packages/52/93/342cc62a70ab727e093ed98e02a725d85b746345f05d2b5e5034649f4ec8/chevron-0.14.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "df793330e2c0cc54fcfa744e09d480af",
"sha256": "87613aafdf6d77b6a90ff073165a61ae5086e21ad49057aa0e53681601800ebf"
},
"downloads": -1,
"filename": "chevron-0.14.0.tar.gz",
"has_sig": false,
"md5_digest": "df793330e2c0cc54fcfa744e09d480af",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11440,
"upload_time": "2021-01-02T22:47:59",
"upload_time_iso_8601": "2021-01-02T22:47:59.233688Z",
"url": "https://files.pythonhosted.org/packages/15/1f/ca74b65b19798895d63a6e92874162f44233467c9e7c1ed8afd19016ebe9/chevron-0.14.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-01-02 22:47:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "noahmorrison",
"github_project": "chevron",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"tox": true,
"lcname": "chevron"
}