diff --git a/README.md b/README.md index 29c2fdf..a277502 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,79 @@ must run Alteza with trusted code, or in an isolated container. For example, in * i.e., e.g. one must write `link('magic-turtle')` for the file `magic-turtle.md`, and `link('pygments-styles')` for the file `pygments-styles.py.css`. * Directories containing index files should just be referred to by the directory name. For example, the index page `about-me/hobbies/index.md` (or `about-me/hobbies/index.py.html`) should just be linked to with a `link('hobbies')`. +12. **Built-in Functions and Fields** + +
Built-in | +Description | +Availability | +|||
---|---|---|---|---|---|
Page | +Template | +Config | +Index & after |
+||
link |
+... | +✅ | ✅ | ❌ | ✅ | +
path |
+... | +✅ | ✅ | ✅ | ✅ | +
dir |
+... | +✅ | ✅ | ✅ | ✅ | +
Modified Date | +... | +✅ | ✅ | ✅ | ✅ | +
Idea Date | +... | +✅ | ✅ | ✅ | ✅ | +
Title | +The title is either the title YAML field, or if that isn't defined, the .realName of the file, which is the adjusted name of the file without its extension and a date prefix (if present) removed. The title isn't properly available to Python inside the page itself, or from __config__.py , since the page has not been processed when these are executed. If .page is accessed from these (the page or config), or if a title was never defined in the page, then the .realName of the file would be returned.
+ |
+❌ | ✅ | ❌ | ✅ | +
YAML fields & other vars | +... | +❌ | ✅ | ❌ | ✅ | +
readfile |
+Just a simple built-in function defined as: + +``` +def readfile(file_path: str) -> str: + with open(file_path, "r", encoding="utf-8") as someFile: + return someFile.read() +``` + + | +✅ | ✅ | ✅ | ✅ | +
sh |
+This exposes entire sh library. The current working directory (CWD) would be wherever the file being executed is located (regardless of whether the file is a regular page or index page or `__config__.py`, etc). If the file is a template, the CWD would be that of the page being processed. + +See `sh`'s documentation here: https://sh.readthedocs.io/en/latest/ + | +✅ | ✅ | ✅ | ✅ | +