All Projects → noahmorrison → Chevron

noahmorrison / Chevron

Licence: mit
A Python implementation of mustache

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Chevron

K8s
Kubernetes Helm Charts for the ORY ecosystem.
Stars: ✭ 127 (-43.05%)
Mutual labels:  mustache
Apacheexpress
Reliable Server Side Swift ✭ Make Apache great again!
Stars: ✭ 170 (-23.77%)
Mutual labels:  mustache
Micromustache
Ⓜ An extremely fast and small sub-implementation of the {{mustache}} template engine for JavaScript
Stars: ✭ 186 (-16.59%)
Mutual labels:  mustache
Thmsgbrt
My awesome README.md
Stars: ✭ 134 (-39.91%)
Mutual labels:  mustache
Amundsen
Amundsen is a metadata driven application for improving the productivity of data analysts, data scientists and engineers when interacting with data.
Stars: ✭ 2,901 (+1200.9%)
Mutual labels:  mustache
Inlets Pro
Secure TCP and HTTP tunnels that work anywhere
Stars: ✭ 179 (-19.73%)
Mutual labels:  mustache
Svg Sprite
SVG sprites & stacks galore — A low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites of several types along with suitable stylesheet resources (e.g. CSS, Sass, LESS, Stylus, etc.)
Stars: ✭ 1,648 (+639.01%)
Mutual labels:  mustache
Charts
Stars: ✭ 206 (-7.62%)
Mutual labels:  mustache
Spring Boot Email Tools
A set of services and tools for sending emails in a Spring Boot 1.5.x application using a Template Engine
Stars: ✭ 164 (-26.46%)
Mutual labels:  mustache
Swagger Codegen
swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
Stars: ✭ 13,859 (+6114.8%)
Mutual labels:  mustache
Bbmustache
Binary pattern match Based Mustache template engine for Erlang/OTP.
Stars: ✭ 141 (-36.77%)
Mutual labels:  mustache
Helm Charts
Jenkins community Helm charts
Stars: ✭ 154 (-30.94%)
Mutual labels:  mustache
Pihole Kubernetes
PiHole on kubernetes
Stars: ✭ 180 (-19.28%)
Mutual labels:  mustache
Charts
Helm chart repository
Stars: ✭ 128 (-42.6%)
Mutual labels:  mustache
Milk
Milk is Mustache in CoffeeScript -- great with your browser or NodeJS!
Stars: ✭ 192 (-13.9%)
Mutual labels:  mustache
Cost Analyzer Helm Chart
Kubecost helm chart
Stars: ✭ 126 (-43.5%)
Mutual labels:  mustache
Ramhorns
Fast Mustache template engine implementation in pure Rust.
Stars: ✭ 172 (-22.87%)
Mutual labels:  mustache
Hydro Serving
MLOps Platform
Stars: ✭ 213 (-4.48%)
Mutual labels:  mustache
Gluebert
gluebert.js is a tiny helper lazy loading DOM Elements, StyleSheets and JavaScript files using dynamic import and code splitting
Stars: ✭ 194 (-13%)
Mutual labels:  mustache
Swagger Codegen Generators
Stars: ✭ 184 (-17.49%)
Mutual labels:  mustache

PyPI version Build Status Coverage Status

A python implementation of the mustache templating language.

Why chevron?

I'm glad you asked!

chevron is fast

Chevron runs in less than half the time of pystache (Which is not even up to date on the spec). And in about 70% the time of Stache (A 'trimmed' version of mustache, also not spec compliant).

chevron is pep8

The flake8 command is run by travis to ensure consistency.

chevron is spec compliant

Chevron passes all the unittests provided by the spec (in every version listed below).

If you find a test that chevron does not pass, please report it.

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

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 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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].