Skip to content

Instantly share code, notes, and snippets.

@vividsnow
vividsnow / example.pl
Created April 19, 2011 17:26
Draft example of Template::Semantic usage
sub wrap {
my ($self, $data) = @_;
return $self->engine->process($self->path.'/layout.html', {
'//head' => {
'title' => $data->{title},
'./script[last()-1]' => @{$data->{js}}?[map { './@src' => '/js/'.$_.'.js' }, @{$data->{js}}]:undef,
'./link[last()]' => @{$data->{js}}?[map { './@href' => '/css/'.$_.'.css'}, @{$data->{css}}]:undef,
'./script[last()]' => $data->{jscode}?sub { $_ =~ s/\/\*code\*\//$data->{jscode}/; \$_ }:undef,
},
'//body' => {
@vividsnow
vividsnow / s3sync.pl
Created June 18, 2009 09:44
1-way synchronization of your files with S3 storage with auto minify *.css and *.js files and gzip text/* content
#!/usr/bin/perl
# s3sync: 1-way synchronization of your files with S3 storage with auto minify *.css and *.js files and gzip text/* content
use Modern::Perl;
use Amazon::S3;
use Path::Class ();
use IO::Compress::Gzip qw(gzip $GzipError);
use File::MMagic;
use JavaScript::Minifier::XS;