Stamp Template Engine
Stamp

CLI

Stamp CLI is a small, free, BSD-licensed Python library and CLI-script to split an HTML file into building blocks for string based template engines to construct complex web GUIs using a DOM-like approach.

Examples

Stamp CLI can be used to split an HTML design file into multiple html files to be consumed by a (string-based) template engine. This way, you can show the design file to your customers and upgrade the design whenever you want without having to change the code that interacts with the design. For instance, imagine the following HTML design file:


<html>
 <
body>
  <!-- 
cut:block -->
   <
div class="block">
    <!-- 
cut:diamond -->
     <
diamond></diamond>
    <!-- /
cut:diamond -->
   </
div>
  <!-- /
cut:block -->
 </
body>
</
html>


stamp design.html
generating: ./diamond.html
generating: ./block.html
generating: ./layout.html
$_

Each file will contain one snippet of HTML specified by the region markers in the design file. For instance block.html will contain:


<div class="block" >
 <!-- 
paste:diamond -->
</
div>

Special tck-attributes (tck stands for Template Construction Kit) are processed like this:


<img...
data-tck="&src"...
src="demo_image.jpg">
<
input data-tck="&checked" >

becomes:


<img #&src# >
<input #&checked# >