These are a few scripts to manipulate Dreamweaver templates from the
command line (without Dreamweaver). I made these so I could work with
people who use Dreamweaver, without having to purchase or use it
myself. These could also potentially be useful for integrating CGI
scripts with the over-all look of a site designed with Dreamweaver.
They are licensed under the GPL.
See INSTALL for information on how to set up the modules.
There are four scripts included:
| dt-apply |
Apply a template to files |
| dt-new |
Convert a non-Dreamweaver HTML file to be used with a template |
| dt-refresh |
Refresh the template for files |
| dt-remove |
Remove the template from a file |
Do dt-* --help to get specific usage information. All the commands
modify pages in-place (i.e., they overwrite the file).
I'm not sure if there's anything really useful about dt-remove, but...
Download
dw-templates_0.1.tar.gz
browse the code
Dreamweaver templates explained
This is my understanding of how Dreamweaver templates work -- this is
useful if you want to do any editting. I've only looked at the output
of Dreamweaver 2.0 -- maybe 3.0 changes things.
A template looks like a normal HTML file, except that certain portions
are marked editable. Like this:
<!-- #BeginEditable "fieldname" -->
The default contents of this area
<!-- #EndEditable -->
This should seem fairly obvious. The Dreamweaver interface doesn't
seem to allow any way to make elements that are not in the body,
except for the title. These scripts don't make any such assumption,
though.
The default extension for Dreamweaver templates is .dwt, and generally
Dreamweaver puts all templates in /Templates.
The HTML files look very similar to templates. The editable regions
remained marked, but their contents are changed. Another tag is added
to the top (and closed at the bottom) to tell which template has been
used, like:
<!-- BeginTemplate "/Templates/basic.dwt" -->
The entire document...
<!-- EndTemplate -->
I haven't encountered a page with multiple templates, the scripts
don't support it. I don't even know what it means. Dreamweaver also
doesn't put the #BeginTemplate/#EndTemplate quite at the top and
bottom of the page, but I don't know why. The scripts don't follow
this behavior.
The template name ("/Templates/basic.dwt") is relative to the Site
Root ("/"). You define this in Dreamweaver when you set a site up,
but in the scripts you can use the option --root=<some-path>.
In Dreamweaver when you apply a template and a field will be lost, it
gives you an interactive warning. The scripts aren't interactive, but
I save left-over fields at the end of the file in comments, so they
can be retrieved later if you change the field name or use a different
template. Use --drop-unused to get rid of these trailing comments,
-w to get warnings about them for dt-apply.
Use dt-new to import pages that don't currently use a Dreamweaver
template. By default, the title is put into the field "doctitle"
(which is the default for Dreamweaver) and the body is put in
"docbody" (Dreamweaver doesn't have a default for this, so this is
arbitrary on my part).
Hopefully that covers everything. Questions, comments, or bugs can
come to me at ianb@colorstudy.com
Enjoy.