A function that helps users create html files. Allows for easy insertion of repetative blocks of code across html files
For each .html file, create a corresponding .chtml file for it. chtml parses each .chtml file in the current directory to produce a corresponding .html file. There are two types of insertions that we can do: static insertions and dynamic insertions.
At any line in our .chtml file we can include a line {file_name}
that will insert the contents of file_name
at that line verbatim. The {file_name}
must be its own line; only whitespace may be before the "{" and no text at all may be after the "}". file_name
may be of any file type other than .html or .chtml
For example, say we have multiple .html files with the same CSS formatting, we can copy the code in <style>
into its own file, call it mycss.css
and then add {mycss.css}
in its place for all corresponding .chtml files.
Dynamic insertions allow us to pass parameters into the files that are being include. Similar to static insertions they have the following formatting: {file_name 1:text1 2:text2 ...}
and in our file, file_name
, we include ~1
in the place that we want "text1" to be inserted into. The replacement text, e.g. text1, must not contain spaces and the identifier, e.g. 1, must be a whole number greater than or equal to 0.