jonnyfolk has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a basic Bootstrap HTML page, and decided to install a jQuery cookies script to comply with the stupid EU regulations.

#!/usr/bin/perl use strict; use CGI::Carp qw(fatalsToBrowser); use CGI ':standard'; use HTML::Template; print "Content-type:text/html\n\n"; my $path = '/path/'; my $formspace = $path . 'formspace.tt'; my $file_contents; open FH, '<', $formspace or die "Can't open $formspace: $!"; $file_contents = do { local $/; <FH> }; close FH; my $template = HTML::Template->new(filename => $path . 'index.tt'); $template->param(FORMSPACE => $file_contents); print $template->output;

The script picks up the data and templates and prints as I want - no problems.

The problem is that when I include the jQuery cookie script, it doesn't work. That might seem to be a problem with the way I've applied the script. However if I generate the HTML with my script, demo.pl, copy the html generated and paste it into a page demo.html, then the cookie script functions as normal.

Has anybody come across this behaviour before?

Replies are listed 'Best First'.
Re: jQuery cookie function not working with HTML::Template
by Corion (Patriarch) on Sep 07, 2015 at 08:49 UTC

    How does your generated HTML differ from the working HTML?

    Maybe your browser shows a Javascript in the error console?

    Are you sure that your use of cookies actually falls under the EU regulation? The EU regulation only applies to cookies used for tracking and/or advertising. Simple login cookies are exempt for example.

      Thanks for your observations. I hadn't realised that the regulation was limited, so I don't think it would apply to me.

      Also looking at the errors showed me that there was a difference between generated and working - my ftp client was not updating the page as requested! Good advice, with thanks.