Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/donatj/ttouch
Unix `touch` with JavaScript programmable templates. (I'm aware it's insane)
https://github.com/donatj/ttouch
template touch unix
Last synced: 3 days ago
JSON representation
Unix `touch` with JavaScript programmable templates. (I'm aware it's insane)
- Host: GitHub
- URL: https://github.com/donatj/ttouch
- Owner: donatj
- License: mit
- Created: 2018-06-25T20:06:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-13T22:57:50.000Z (6 months ago)
- Last Synced: 2024-10-20T07:30:54.626Z (27 days ago)
- Topics: template, touch, unix
- Language: Go
- Homepage:
- Size: 64.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ttouch
[![Go Report Card](https://goreportcard.com/badge/github.com/donatj/ttouch)](https://goreportcard.com/report/github.com/donatj/ttouch)
[![GoDoc](https://godoc.org/github.com/donatj/ttouch?status.svg)](https://godoc.org/github.com/donatj/ttouch)Unix touch with JavaScript driven templates.
## Installation
```bash
go install github.com/donatj/ttouch/cmd/ttouch@latest
```## Templates
The templating engine runs on the [otto](https://github.com/robertkrimen/otto) JavaScript runtime which targets ES5.
Templates are searched for in `.ttouch` directories staring in your current
working directory down to the root.Templates are named all lowercase `{ext}.js` or `{filename}.js` - for example `md.js` for all `.md` files, or `readme.md.js` to match `README.md`. Filename matches take precidence over extension matches.
The template string is the result of the final execution of the JS file. For example, a dead simple template could be:
```js
"#!/bin/sh\n";
```If you want a little more control or clarity, you can wrap that in a function call:
```js
(function () {
return "#!/bin/sh\n";
})();
```