29 Jan 17:25
[FormBuilder] Hmm, Here is a patch which will remove auto generated comment in result html, Also, with small enhancement. ; -)
From: Yiyi Hu <yiyihu <at> gmail.com>
Subject: [FormBuilder] Hmm, Here is a patch which will remove auto generated comment in result html, Also, with small enhancement. ; -)
Newsgroups: gmane.comp.lang.perl.modules.formbuilder
Date: 2007-01-29 16:26:21 GMT
Subject: [FormBuilder] Hmm, Here is a patch which will remove auto generated comment in result html, Also, with small enhancement. ; -)
Newsgroups: gmane.comp.lang.perl.modules.formbuilder
Date: 2007-01-29 16:26:21 GMT
Hello, All. FormBuilder rocks anyway. But normally, There is something we don't want. In any case, You don't like to see the message like <!-- Generated by CGI::FormBuilder v$VERSION available from www.formbuilder.org --> But It seems there is no option to remove this without patching the source. Touch symbol table works fine. But doesn't work well when we are in Catalyst::Controller::FormBuilder. So this patch did this. It won't show the hidden trailer if you set debug option off. Another small enhancement is. I add a browser_compat option (Default is 1). The one which most people like.If It is set to 0. Then, You won't see the <!-- hide from old browsers blablabla //--> Things in generated javascript. Modern browsers. Even lynx and w3m, can deal with unknown tags correctly. And I need this feature also.
Any suggestions welcome. Xinming
diff -Pur CGI-FormBuilder-3.05/lib/CGI/FormBuilder/Util.pm CGI-FormBuilder-3.05_modified/lib/CGI/FormBuilder/Util.pm
--- CGI-FormBuilder-3.05/lib/CGI/FormBuilder/Util.pm 2006-12-18 18:46:28.000000000 +0800
+++ CGI-FormBuilder-3.05_modified/lib/CGI/FormBuilder/Util.pm 2007-01-29 23:54:49.613939000 +0800
@@ -63,7 +63,7 @@
# specified in the generation of HTML tags, and also means that this
# module doesn't go out of date when the HTML spec changes next week.
our @OURATTR = qw(
- attr autofill autofillshow body bodyname buttonname caller checknum cleanopts
+ attr autofill autofillshow body bodyname browser_compat buttonname caller checknum cleanopts
columns cookies comment debug delete dtd errorname extraname fields
fieldattr fieldsubs fieldtype fieldname fieldopts fieldset fieldsets
font force formname growable growname header idprefix inputname invalid
diff -Pur CGI-FormBuilder-3.05/lib/CGI/FormBuilder.pm CGI-FormBuilder-3.05_modified/lib/CGI/FormBuilder.pm
--- CGI-FormBuilder-3.05/lib/CGI/FormBuilder.pm 2006-12-18 18:46:28.000000000 +0800
+++ CGI-FormBuilder-3.05_modified/lib/CGI/FormBuilder.pm 2007-01-30 00:03:54.785007487 +0800
@@ -51,6 +51,7 @@
selectnum => 5,
stylesheet => 0, # use stylesheet stuff?
styleclass => 'fb', # style class to use
+ browser_compat => 1, # auto insertion of <!-- -->
# For translating tag names (experimental)
tagnames => { },
# I don't see any reason why these are variables
@@ -962,13 +963,20 @@
$self->{onsubmit} ||= "return $jsname(this);";
}
+ my $js_body = "\n" . $jshead . $jsmisc . $jsfunc;
+ if ($self->{browser_compat}) {
+ $js_body =
+ "<!-- hide from old browsers"
+ #. "<![CDATA[" # fucking web "standards"
+ . $js_body
+ #. "\n]]>"
+ . "//-->\n";
+ }
+
# set <script> now to the expanded javascript
return '<script type="text/javascript">'
- . "<!-- hide from old browsers\n"
- #. "<![CDATA[\n" # fucking web "standards"
- . $jshead . $jsmisc . $jsfunc
- #. "\n]]>"
- . "//-->\n</script>";
+ . $js_body
+ . '</script>';
}
sub script_growable {
@@ -1187,7 +1195,7 @@
sub version {
# Hidden trailer. If you perceive this as annoying, let me know and I
# may remove it. It's supposed to help.
- return '' if $::TESTING;
+ return '' if $::TESTING || (!$_[0]->{'debug'});
if (ref $_[0]) {
return "\n<!-- Generated by CGI::FormBuilder v$VERSION available from www.formbuilder.org -->\n";
} else {
_______________________________________________ FBusers mailing list FBusers <at> formbuilder.org http://www.formbuilder.org/mailman/listinfo/fbusers
If It is set to 0.
Then, You won't see the
<!-- hide from old browsers
blablabla
//-->
Things in generated javascript.
Modern browsers.
Even lynx and w3m, can deal with unknown tags correctly.
And I need this feature also.
RSS Feed