craigt has asked for the wisdom of the Perl Monks concerning the following question:
I'm working on a Windows platform using an Apache server and dHTML - HTML, CSS, JavaScript, Perl/CGI, and a number of APIs. I have a custom parameter file that's read into a CGI module. The parameters in that file allow a user to customize the geography and appearance of the application. The parameters in that file are embedded in the CSS, JavaScript, and Perl code in the CGI module. I define my Perl namespaces at the beginning of the module, with names like $navytext. I then read the custom parameter file into an array. The parameters in the file have the same names as the namespaces I define in the CGI module. I split the comment portion of each parameter line off and eval the parameter value into the CGI module where it is then used downstream in CSS, JavaScript, and Perl. A simplified code example follows.
my $navytext; # This variable appears as the line '$navytext = '000066 +' # Navy blue text.' in the custom parameters file below. . . . my $cpsfnx = $thepdir . 'custom.parms'; if (-e $cpsfnx) { my @cpslnsx = in_shared($cpsfnx); my $cpsln = ''; foreach $cpsln (@cpslnsx) { if (index($cpsln,'#') > 1) { ($cpsln,$tmp) = split ('#',$cpsln); } eval($cpsln); } } . . . <HEAD> <STYLE> #tabmenu { color: #$navytext; }
Notice in the example that the CSS with the Perl namespace $navytext resides right in the Perl module. This has all worked well for some time. Now I would like to remove the CSS from the Perl module, put it in a CSS file, and link the CSS file into the Perl module. When I do this, the Perl variable no longer resolves correctly to the HTML color and the CSS does not work. I have tried to quote the Perl variable in the CSS file in several ways with no luck. The question is can I link an external CSS file with embedded Perl variables into a CGI module so that the Perl variables resolve correctly?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl variables embedded in CSS in a CSS file not resolving correctly when the file is linked in
by Corion (Patriarch) on Oct 05, 2018 at 14:02 UTC | |
by craigt (Acolyte) on Oct 05, 2018 at 14:54 UTC |