This repository has been archived by the owner on Jun 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
mkpage.html
126 lines (98 loc) · 3.78 KB
/
mkpage.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html>
<head>
<title>Caltech Library's Digital Library Development Sandbox</title>
<link rel="stylesheet" href="/css/site.css">
</head>
<body>
<header>
<a href="http://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a>
</header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="../">Up</a></li>
<li><a href="./mkrss.html">mkrss</a></li>
<li><a href="./mkpage.html">mkpage</a></li>
<li><a href="./urlencode.html">urlencode</a></li>
<li><a href="./go-template-recipes.html">Go text/template recipes</a></li>
<li><a href="./titleline.html">titleline</a></li>
<li><a href="./mkslides.html">mkslides</a></li>
<li><a href="./slides/three-slides.html">Title Page</a></li>
<li><a href="./slides/presentation.html">What is mkslides?</a></li>
<li><a href="./byline.html">byline</a></li>
<li><a href="./ws.html">ws</a></li>
<li><a href="./frontmatter.html">frontmatter</a></li>
<li><a href="./mkpongo.html">mkpongo</a></li>
<li><a href="./urldecode.html">urldecode</a></li>
<li><a href="./sitemapper.html">sitemapper</a></li>
<li><a href="./reldocpath.html">reldocpath</a></li>
</ul>
</nav>
<section>
<h1>mkpage</h1>
<h2>USAGE</h2>
<pre><code>mkpage [OPTION] [KEY/VALUE DATA PAIRS] TEMPLATE_FILENAME [TEMPLATE_FILENAMES]
</code></pre>
<h2>SYNOPSIS</h2>
<p>Using the key/value pairs populate the template(s) and render to stdout.</p>
<h2>CONFIGURATION</h2>
<p>You can set a local default template path by using environment variables.</p>
<ul>
<li>MKPAGE_TEMPLATES - is the colon delimited list of template paths</li>
</ul>
<h2>OPTIONS</h2>
<pre><code> -default-template Use the default template
-h show help
-help show help
-l show license
-license show license
-s display the default template
-show-template display the default template
-t colon delimited list of templates to use
-templates colon delimited list of templates to use
-v show version
-version show version
</code></pre>
<h2>EXAMPLE</h2>
<p>Template (named “examples/weather.tmpl”)</p>
<pre><code> {{ define "weather.tmpl" }}
Date: {{- .now}}
Hello {{.name -}},
The current weather is
{{index .weatherForecast.data.weather 0}}
Thank you
{{.signature}}
{{ end }}
</code></pre>
<p>Render the template above (i.e. examples/weather.tmpl) would be accomplished from
the following data sources–</p>
<ul>
<li>“now” and “name” are strings</li>
<li>“weatherForecast” is JSON data retrieved from a URL
+ “.data.weather” is a data path inside the JSON document
<ul>
<li>“index” let’s us pull our the “0”-th element (i.e. the initial element of the array)</li>
</ul></li>
<li>“signature” comes from a file in our local disc (i.e. examples/signature.txt)</li>
</ul>
<p>That would be expressed on the command line as follows</p>
<pre><code class="language-shell"> mkpage "now=text:$(date)" "name=text:Little Frieda" \
"weatherForecast=http://forecast.weather.gov/MapClick.php?lat=13.47190933300044&lon=144.74977715100056&FcstType=json" \
signature=examples/signature.txt \
examples/weather.tmpl
</code></pre>
<p>Golang’s text/template docs can be found at</p>
<pre><code> https://golang.org/pkg/text/template/
</code></pre>
</section>
<footer>
<span><h1><A href="http://caltech.edu">Caltech</a></h1></span>
<span>© 2020 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span>
<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address>
<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span>
<span><a href="mailto:library@caltech.edu">Email Us</a></span>
<a class="cl-hide" href="sitemap.xml">Site Map</a>
</footer>
</body>
</html>