(Video materials in preparation)
formmrg : Merges characters into an HTML template
Usage : formmrg <html_template> <data>
Option : -n<string>
-s<c>
-e
--form <formname>
Version : Thu Sep 21 16:00:09 JST 2017
Edition : 1
Inserts the values from the <data> name form file (First field: tag
name, Subsequent fields: values) into the input tags (checkbox color
date datetime datetime-local email hidden month number radio range
search tel text time url week), textarea tags and select tags of the
$ cat html
<html><body>
<form name="name_form">
<input type="text" name="name_text1" />
<input type="text" name="name_text2" />
<input type="radio" name="name_radio" value="a"/>
<input type="radio" name="name_radio" value="b"/>
<input type="checkbox" name="name_checkbox" value="x"/>
<input type="checkbox" name="name_checkbox" value="y"/>
<textarea name="name_textarea">
</textarea>
<select name="name_pulldown">
<option value="pd1">pd1</option>
<option value="pd2">pd2</option>
<option value="pd3">pd3</option>
</select>
<input type="submit" name="submit" />
</form>
</body></html>
$ cat data
name_text1 hello
name_text2
name_radio b
name_checkbox y
name_textarea usp\nlaboratory
name_pulldown pd3
$ formmrg html data
<html><body>
<form name="name_form">
<input type="text" name="name_text1" value="hello" />
<input type="text" name="name_text2" />
<input type="radio" name="name_radio" value="a"/>
<input type="radio" name="name_radio" value="b" checked="checked" />
<input type="checkbox" name="name_checkbox" value="x"/>
<input type="checkbox" name="name_checkbox" value="y" checked="checked" />
<textarea name="name_textarea">
usp
laboratory
</textarea>
<select name="name_pulldown">
<option value="pd1">pd1</option>
<option value="pd2">pd2</option>
<option value="pd3" selected="selected" >pd3</option>
</select>
<input type="submit" name="submit" />
</form>
</body></html>
1. If an input already has a value set with value="" in the
template, the value is overwritten. Similarly, the value in a
textarea template will be overwritten. For select tags, if
an option is already marked selected="selected" in the template,
the attribute is moved to the merged value.
2. For textarea tags, the existing value is overwritten. Also,
"\n" is converted to a linefeed.
3. If no value is specified in the template, no value is merged.
4. If the -n option is set, then any string matching the specified
string is converted to null and inserted.
5. If the -s option is used, then any character matching the specified
character is converted to a space and inserted.
However, data in the format \<specified_char> will not be replaced
by a space.
For select, radio and checkbox, checked="checked" is inserted where
the name and value are the same in the name file, so the -s option
is ignored.
6. The HTML must be written properly. For example, all tags must be in
lowercase and written as <tag /> or <tag> </tag>.
Variables must be enclosed in double quotes. (i.e. value="1")
For input type="checkbox", always set the value as value="XXX".
7. If you want to select multiple options for checkbox, radiobox or
selectbox, the name data should be specified with the same tag on
multiple lines.
name_radio a
name_radio b
name_checkbox x
name_checkbox y
name_pulldown pd1
name_pulldown pd2
The old -d option (current -s option) is not suported.
The old -i option (current -n option) is not suported.