Skip to main content

An amazing web prototyping tool

Project description

Clay

Coverage Status Tests

An amazing prototyping tool.

With Clay you can forget about making changes to dozens of HTML files just because you need to add a link in the footer.

You can also use it to prototype your AJAX-driven application or the responses of sending forms, because it acts like a real server.

Install

uv tool install clay

Quickstart

clay new mysite

will generate a new app container with the following structure:

mysite
  ├── static/
  ├── clay.yaml
  ├── index.html
  └── ...other files

You can also use an optional project template path or git URL. For the URLs, "gh:" works as a shortcut of "https://github.com/" and "gl:" as a shortcut of "https://gitlab.com/". For example:

# Absolute or relative path.
clay new myapp /path/to/project/template

# GitHub repo. Note the ".git" postfix.
clay new myapp https://github.com/lucuma/clay-template.git

# The same GitHub repo with shortcut
clay new myapp gh:/lucuma/clay-template.git

Development server

Inside that folder, run the development server with:

clay run

and your site'll be available at http://0.0.0.0:8080/.

Anything inside the static folder is served as-is under the /static/ path. For example you can see myapp/static/image.png at the http://0.0.0.0:8080/static/image.png URL.

Any file outside the static folder, is rendered as a page.

For example, myapp/page.html is rendered and shown at http://0.0.0.0:8080/page.html, as an HTML page.

And myapp/foo/bar.json is rendered and shown at http://0.0.0.0:8080/foo/bar.json as a JSON document.

Remember to put inside static anything you don't want to be rendered.

Build version

To generate a static version of your site, first, stop the server with Control + C, and then run:

clay build

and all the templates will be processed and the result stored inside the build folder.

Static files

If you have folders in your project, you might be tempted to write internal URLs like this

<!-- DON'T DO THIS ->
href="../a.html"
src="../static/main.js"

Don't do it. Is error-prone and could not work as expected if you do it in a base layout, for example. Always write the internal URLs using their path from the root of the project, like this:

href="/a.html"
src="/static/main.js"

That'll work on the development server and also when generating a static version of your site, Clay will convert them into relative paths automatically.

Template globals

When writing your templates, in addition of what is normally available in Jinja templates you have access to some other helper functions:

  • The python's functions dir, enumerate, map, zip, and len.
  • The now function, as an alias to datetime.datetime.utcnow.
  • The active function, to set an "active" class in navigations/menus when the current page match.

active()

active(*url_patterns, partial=False, class_name="active")

TODO

The clay.yaml file

If a YAML file named clay.yaml is found in the root of the project, it will be read and used for configuring Clay.

---
# Shell-style patterns files/folders that must not be copied.
# Use quotes.
exclude:
  - ".*"
  - ".*/*"
  - "~*"
  - "~*/*"
  - "_*"
  - "_*/*"
  - "*.txt"

# Shell-style patterns files/folders that *must be* copied, even if
# they are in the exclude list.
# Use quotes.
include:
  - "robots.txt"
  - "humans.txt"

# Jinja extensions to use
jinja_extensions:

# Shell-style patterns of files outside `static/` that must be copied
# as-is instead of trying to interpret them as Jinja templates.
# Use quotes.
binaries:
  - "favicon.ico"

Happy coding!

Development

Create the project environment and install all development dependencies:

uv sync

Run the test and lint suites through the locked project environment:

uv run pytest -x clay tests
uv run flake8 --config=setup.cfg clay tests

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

clay-4.7.0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

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

clay-4.7.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file clay-4.7.0.tar.gz.

File metadata

  • Download URL: clay-4.7.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clay-4.7.0.tar.gz
Algorithm Hash digest
SHA256 a1da639f0d83dc6759a7ac0492b7fd129a1e7e5e3f1fe6dfe07875722f4be7d5
MD5 40cf0691f3e0bb16be233810cbd41c8e
BLAKE2b-256 1204c02e721298fe16df94b8489eed4b5b7bc5e05fe77116afcf785f5897fb9c

See more details on using hashes here.

File details

Details for the file clay-4.7.0-py3-none-any.whl.

File metadata

  • Download URL: clay-4.7.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clay-4.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f5d5a804afbd4de3f4051698689e185a16c53ff5581c9dbf16cd9d118cb3fa1
MD5 751d30d786d3356c093eab4147bb77ee
BLAKE2b-256 d8ee797ad75fdeae19a3f0ae4ce947597489a3d5a11493a4863863f8d4d755fe

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