[ create a new paste ] login | about

Link: http://codepad.org/4aHsEHbA    [ raw code | output | fork ]

rplantiko - Perl, pasted on Aug 1:
# Since the DRY violation of repeating color codes in CSS bothered me,
# I made a meta-CSS in the form of a simplistic perl file

# The simplest way to do this in Perl is by using the built-in 
# variable substitution mechanism (interpolation)

# Use this file index.css.tmpl.pl to generate index.css
# Don't change the target index.css manually

# Predefined color codes of my color scheme
$COLOR_BACKGROUND            = "#E5E879";
$COLOR_HEADING_BACKGROUND    = "#7C79E8";
$COLOR_SUBHEADING_BACKGROUND = "#97275C";
$COLOR_ALTERNATE_1           = "#E879AD";
$COLOR_ALTERNATE_2           = "#79E8B4";
$COLOR_ALTERNATE_3           = "#292797";

# Productive version:
# open CSS, ">index.css" or die "Can't open index.css";
# --- Codepad version, to see it work
  *CSS = *STDOUT;  
  
print CSS <<CSS_TEMPLATE;

/* index.css is a generated file. Do not change it manually.
   Use the template index.css.tmpl.pl for changes */

body {
  background-color:$COLOR_BACKGROUND;
  }

h1 {
  background-color:$COLOR_HEADING_BACKGROUND;
  color:white;
  padding:10px 0px;
  text-align:center;
  }

... and so on ...

CSS_TEMPLATE

close CSS;


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

/* index.css is a generated file. Do not change it manually.
   Use the template index.css.tmpl.pl for changes */

body {
  background-color:#E5E879;
  }

h1 {
  background-color:#7C79E8;
  color:white;
  padding:10px 0px;
  text-align:center;
  }

... and so on ...



Create a new paste based on this one


Comments: