HTML::Template::Filter::Dreamweaver - a module that provides a filter function to translate Dreamweaver MX Template pages (.dwt) to HTML::Template pages
use HTML::Template::Filter::Dreamweaver qw( DWT2HTML ); use HTML::Template; my $template = new HTML::Template( filename => "foo.dwt", filter => \&DWT2HTML, ); print $template->output;
For the most part this module should work exactly how you expect it should. There are a few features in this module that Dreamweaver designers should know about.
Escaping. HTML::Template allows variables to be HTML escaped or URL escaped. I do not know how to specify this in Dreamweaver, so I invented a syntax.
In the <!-- TemplateParam --> section, you can specify an escaping scheme that you would like to use. For example, <!-- TemplateParam name="foo" type="text" value="yes & no" escape="HTML" --> would mean that the "foo" variable would be HTML escaped whenever it is used. If you wish to override the escaping scheme provided by the <!-- TemplateParam --> section, you can do this in the <!-- TemplateExpr --> section. For example, to get URL escaping, do the following: <!-- TemplateExpr expr="foo" escape="HTML" --> An alternative syntax would be the following @@(_document._Get( "foo", "HTML" ))@@
The filter should be able to translate Dreamweaver templates into something that could be understood by HTML::Template::Expr. However, it will only attempt to do this if the filter is being used from within HTML::Template::Expr. It does this by looking at the caller stack. If for some reason this is not working correctly, you can force the filter to convert into HTML::Template::Expr syntax by using the function DWT2HTMLExpr
While we are on the Expr subject... I believe it will work in most cases. Just remember that this is a fairly dumb filter. It will translate things like '==' to ' eq ' for text strings, but that is about it. In other words, there are some warnings about how expressions should be written within the HTML::Template::Expr documentation. Heed those warnings, because this filter will not fix the problems for you.
Dreamweaver supports ternary logic (i.e, foo > 5 ? "yes" : "no" ), but HTML::Template::Expr does not. I put in a very basic test to try to convert these into IF-ELSE clauses.
HTML::Template allows you to not put quotes around variables and words. For example, you could say <TMPL_VAR NAME=foo ESCAPE=HTML>. DWT2HTML is not so nice. It expects quotes (either single or double) around those things. I believe that Dreamweaver also requires the same, so this should not be an issue unless you are hand editing code.
Brian Paulsen (<lt>brian@thepaulsens.com<gt>)
HTML::Tempate and HTML::Tempate::Expr
perl.
To install HTML::Template::Filter::Dreamweaver, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::Template::Filter::Dreamweaver
CPAN shell
perl -MCPAN -e shell install HTML::Template::Filter::Dreamweaver
For more information on module installation, please visit the detailed CPAN module installation guide.