Skip to main content

Stenciler

stenciler is a CLI tool for building plaintext artifacts by populating Jinja templates from YAML files. You can use it in any case where you need to create one or more different plaintext formats with the same data, e.g. a resume in .txt and .tex formats.

Installation

pipx install stenciler

Example Usage

Here is an example use case. These files can also be found in the sample directory.

Say you need to build a sample resume in .txt and .tex formats. First, set up your data:

# resume.yaml
name: Marie Curie
summary: |
    Physicist, chemist, two-time Nobel Prize winner, enjoys long bicycle trips.
awards:
- name: Nobel Prize in Chemistry
  year: 1911
- name: Albert Medal
  year: 1910
- name: Davy Medal
  year: 1903
- name: Nobel Prize in Physics
  year: 1903

Now, set up your stencil. This yaml file should have a simple dictionary structure where the keys are file extensions (e.g. txt, tex) and the values are Jinja templates.

# stencil.yaml
txt: |
  Name:       {{ name }}

  SUMMARY
  ----------------------------------------------------------------------------------
  {{ summary | replace('\n', ' ') | wordwrap(80) }}

  AWARDS
  ----------------------------------------------------------------------------------
  {% for award in awards %}{{ award.name }}{{ " " * (78 - award.name.__len__()) }}{{ award.year}}
  {% endfor %}
tex: |
  \documentclass{article}
  \begin{document}
  {\huge\centering {{ name }}\\[-0.7\baselineskip]\hrulefill\par}

  \subsection*{Summary}
  {{ summary | replace('\n', ' ') | wordwrap(80) }}

  \subsection*{Education}
  {% for award in awards %}
  \noindent {{ award.name }} \hfill {{ award.year }}
  {% endfor %}

  \end{document}

Last, run stenciler to generate the output files:

stenciler --stencil stencil.yaml --data resume.yaml

Results:

# outputs/resume.txt
Name:       Marie Curie

SUMMARY
----------------------------------------------------------------------------------
Physicist, chemist, two-time Nobel Prize winner, enjoys long bicycle trips.

AWARDS
----------------------------------------------------------------------------------
Nobel Prize in Chemistry                                                      1911
Albert Medal                                                                  1910
Davy Medal                                                                    1903
Nobel Prize in Physics                                                        1903
# outputs/resume.tex
\documentclass{article}
\begin{document}
{\huge\centering Marie Curie\\[-0.7\baselineskip]\hrulefill\par}

\subsection*{Summary}
Physicist, chemist, two-time Nobel Prize winner, enjoys long bicycle trips.

\subsection*{Education}

\noindent Nobel Prize in Chemistry \hfill 1911

\noindent Albert Medal \hfill 1910

\noindent Davy Medal \hfill 1903

\noindent Nobel Prize in Physics \hfill 1903


\end{document}

Screenshot of compiled resume.pdf

Developer Setup

Set up your virtual environment:

python3 -m venv .venv

Assuming direnv, set up your .envrc:

# .envrc
PATH_add .venv/bin
PATH_add bin

chmod -R +x bin

Allow your env file and install requirements:

direnv allow
pip install -r dev-requirements.txt

Run the test script:

checks

Metadata

Release files for stenciler 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stenciler 0.1.1
File Size Uploaded
stenciler-0.1.1.tar.gz 4.1 kB Details

Release files / stenciler-0.1.1.tar.gz

Download URL stenciler-0.1.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9395b552410008c147194b2417df5c23443043d9e3f1fab7a5d8c403ff48e8b8
BLAKE2b-256 checksum
How to use checksums
f200cbc0060d847fae5a3af435ec29fb3d01b27c4ff6077a97171171cc5e5d6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.10

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page