esh is a templating engine for evaluaing shell commands embedded in arbitrary templates.
Lines between the start and end token are evaluated by the shell. A start token followed by a = is syntactic sugar for echo, printing the following contents.
Like many other templating engines esh supports a front matter section for defining variables. This section is enclosed by two freestanding lines containing --- at the beginning of the file.
esh will default to reading from stdin if no file parameter is given and prints the result to stdout.
- 0
-
Success
- 2
-
Failure (illegal parameter; file not found; syntax error within the template/embedded shell).
Example of an html template displaying the current directory contents in a list.
<!DOCTYPE html>
<html>
<body>
<ul>
<% for i in $(ls); do %>
<li><%= $i %></li>
<% done %>
</ul>
</body>
</html>
To generate the resulting html run:
esh example.html.esh > example.html
Another example showing the esh front matter capabilities.
---
title="Test" # Make sure to use valid shell assignments!
---
<!DOCTYPE html>
<html>
<body>
<h1><%= $title %></h1>
<ul>
<% for i in $(ls); do %>
<li><%= $i %></li>
<% done %>
</ul>
</body>
</html>