Skip to main content

hsx - Hypertext, templating with XML-like evaluation inspired by JSX

Project description

hsx

Version: 0.0.2

hsx is a small macro-style preprocessor for static content.

It replaces XML-like tags in a source file with the contents of fragment files stored in a directory.

Fragments are plain text files (for example markdown, HTML, CSS) and are included by tag name composited using JSX like instructions. (hence the name)

Code Maturity

This code is experimental, and version 0.0.1 See SEMVER.md for how I use semantic versioning

Author

Michael Sparks (sparks.m@gmail.com / https://github.com/sparkslabs )

What it does

Replaces <Tag /> with the contents of Tag.<extension> from a fragment directory.

  • Supports attributes: <Tag key="value" /> with {args.key} substitution.

  • Supports block tags: <Tag> ... </Tag> with {args.__text__} substitution.

  • Supports nested tags.

  • Evaluates fragments recursively with a bounded recursion depth.

Deliberately fails on structural mismatches (eg misordered closing tags). It does not implement loops, conditionals, or a templating language.

Usage

Assuming copied onto your path somewhere

hsx.py

hsx.py [OPTIONS]

Where options are:

  • --dir <directory> Fragment directory
  • --extension <ext> Fragment file extension
  • --destfile <filename> Write output to file instead of stdout
  • --file <filename> Filename to process

Defaults:

  • Fragment directory: frags

  • Fragment extension: .hsx

  • Source file: markdown.hsx

Bonus mkAutoSite.py

mkAutoSite is intended to use hsx - in particular it's designed to statically compile a collection of templates, HSX files, and markdown files to a static website.

This is put here for the moment as an expediency to eradicate having 10 copies across my filesystem.

Plan for Autosite

Extend current template processing to build templates from HSX files

License

Apache License 2.0 (as usual)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hsx-0.0.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hsx-0.0.2-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file hsx-0.0.2.tar.gz.

File metadata

  • Download URL: hsx-0.0.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hsx-0.0.2.tar.gz
Algorithm Hash digest
SHA256 86d16810dcad35e39443c6130d0091d4a9e88af35f8e771178f4e0a087813147
MD5 296a4ab56509b802355f015ed75580f8
BLAKE2b-256 0aaef215521c4e5c06966624953c9066aefba4277a8997fef73a6b44ae40040c

See more details on using hashes here.

File details

Details for the file hsx-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: hsx-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hsx-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aab46c779e6cb336feab6621cb15c7514498744683bf4dfbbc244ac54df15728
MD5 435fe7135f948e61ae4cce01de91fa44
BLAKE2b-256 1243f343797236c9ecf42f58aeeb26ba486523f7d9f248d58c4dfb3c9d955a23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page