~ecs/wersh

static site generator based on POSIX sh
rewrite the thing
Miscellaneous fixes

refs

wersh
browse  log 

clone

read-only
https://git.d2evs.net/~ecs/wersh
read/write
git@git.d2evs.net:~ecs/wersh

You can also use your local clone with git send-email.

static site generator in posix shell, loosely inspired by werc

based on https://git.sr.ht/~sircmpwn/wersh but i got bored one day and decided
to rewrite it from scratch, it's a lot better now

usage: wersh [<input> [<output>]]

wersh takes files under <input>/ and converts them into files under <output>.
files and directories that start with _ are ignored, files that don't end in .w
are copied verbatim, and files ending in .w are turned into shell scripts and
sourced, with stdout written to the output directory

processing for .w files:
- %%% starts/ends a literal block, lines within a block are copied verbatim into
  the script
- lines starting with "% " are copied verbatim into the script
- other lines are wrapped in a printf, such that they end up on stdout directly

wersh also sets some handy dandy environment variables:
- root: <input>
- outputdir: <output>
- input: current input file
- output: current output file

don't use variables starting with "wersh_" in your shell scripts

there are also a few handy dandy functions:
- wsource is like source but does .w processing
- escape does very halfhearted html escaping. if you feel like thinking harder
  about it and making it better then have fun

you can do templates by overriding the render() in a template script and
sourcing that script from any files that use it. render() gets the script's
output on stdin and should write the final output to stdout

if <input>/_config.sh exists, it'll be sourced (without .w processing)
immediately before processing any .w file

see example/ for an example wersh site. it's currently broken lmao i'll fix it
eventually, but ./wersh example should produce a static site in _site/ that you
can serve with your httpd of choice

misc stuff that's here for compatibility with ~sircmpwn/wersh but i'll probably
get rid of in the future:
- scripts are also piped through $preprocessor. you should just use render for
  this
- there's an emit function which just does printf %s\\n "$@"