From: Advaith Menon Date: Tue, 2 Dec 2025 15:14:10 +0000 (-0500) Subject: Update README and LICENSE X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;ds=inline;p=chevron.git Update README and LICENSE * Update README to standard text-based format used by DIT * Add author information and copyright in both README and LICENSE --- diff --git a/LICENSE b/LICENSE index 8138aa8..6ff3318 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ The MIT License (MIT) -Copyright (c) 2014 Noah Morrison +Copyright (c) 2014 Noah Morrison, et al. +Copyright (c) 2025 Advaith Menon d/b/a Devi Nivas DIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README b/README new file mode 100644 index 0000000..342d8af --- /dev/null +++ b/README @@ -0,0 +1,145 @@ +=============================================================================== + DEVI NIVAS DEPARTMENT OF INFORMATION TECHNOLOGY + MUSTACHE PARSER (CHEVRON) FORK +=============================================================================== + +TABLE OF CONTENTS + 1. Abstract + 2. Usage + 3. Installation + 4. Copyright + + +ABSTRACT + A fork of Noah Morrison's chevron. This fork aims to allow using a custom + escape function (intended for use with LaTeX) and also aims to fix any + security and compatibility issues for the forseeable future. + +USAGE + COMMAND-LINE: + + 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: + + import chevron + + chevron.render('Hello, {{ mustache }}!', {'mustache': 'World'}) + + + Python usage with file + + import chevron + + with open('file.mustache', 'r') as f: + chevron.render(f, {'mustache': 'World'}) + + + PYTHON USAGE WITH UNPACKING: + + import chevron + + args = { + 'template': 'Hello, {{ mustache }}!', + + 'data': { + 'mustache': 'World' + } + } + + chevron.render(**args) + + + CHEVRON SUPPORTS PARTIALS (VIA DICTIONARIES): + + import chevron + + args = { + 'template': 'Hello, {{> thing }}!', + + 'partials_dict': { + 'thing': 'World' + } + } + + chevron.render(**args) + + + CHEVRON SUPPORTS PARTIALS (VIA THE FILESYSTEM): + + 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: + + 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 git://git.devinivas.org/chevron.git + + + or using submodules + + $ git submodules add git://git.devinivas.org/chevron.git + +COPYRIGHT + Copyright (c) 2014-2021 Noah Morrison et al. + Copyright (c) 2025 Advaith Menon d/b/a Devi Nivas DIT + Licensed under the MIT license. diff --git a/README.md b/README.md deleted file mode 100644 index 8c9de75..0000000 --- a/README.md +++ /dev/null @@ -1,177 +0,0 @@ -[![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