WhyML is a powerful Python package that transforms YAML manifests into multiple output formats including HTML, React, Vue, and PHP. This guide will help you get started quickly with WhyML.
pip install whyml
git clone https://github.com/dynapsys/whyml.git
cd whyml
pip install -e .
git clone https://github.com/dynapsys/whyml.git
cd whyml
pip install -e ".[dev]"
Create a simple manifest file example.yaml:
metadata:
title: "My First Page"
description: "Learning WhyML basics"
styles:
body:
font-family: "Arial, sans-serif"
margin: "0"
padding: "20px"
structure:
html:
children:
- head:
children:
- title:
text: ""
- body:
children:
- h1:
text: "Welcome to "
- p:
text: ""
Convert to HTML:
whyml convert --from example.yaml --to example.html --as html
Scrape an existing website and convert it to a YAML manifest:
whyml scrape https://example.com --output scraped.yaml --simplify-structure
Convert your YAML manifest to different formats:
# Convert to React component
whyml convert --from example.yaml --to Example.tsx --as react
# Convert to Vue component
whyml convert --from example.yaml --to Example.vue --as vue
# Convert to PHP component
whyml convert --from example.yaml --to Example.php --as php
The easiest way to get started is using our provided scripts:
# Run the complete Example 1 workflow
./scripts/examples/run-example-1.sh
# Or run all examples at once
./scripts/run-all-examples.sh
These scripts will:
A WhyML manifest consists of several key sections:
Use `` syntax to insert dynamic content:
variables:
site_name: "My Website"
primary_color: "#007bff"
structure:
h1:
text: "Welcome to "
style: "color: "
WhyML supports template inheritance for reusable components:
extends: "base-template.yaml"
metadata:
title: "Child Page"
# Override or extend parent template
Check out the examples directory for complete working examples:
For common issues and solutions, see our Troubleshooting Guide.
See our Contributing Guide for information on how to contribute to WhyML.