Skip to content

Instantly share code, notes, and snippets.

@hideo55
Created August 1, 2011 17:18
Show Gist options
  • Save hideo55/1118563 to your computer and use it in GitHub Desktop.
Save hideo55/1118563 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl -w
use strict;
use Text::Xslate;
use AnyEvent::JSONRPC::Lite::Server;
use Getopt::Long;
my ( $port, $template_path );
GetOptions( "port=i" => ¥$port, "path=s" => ¥$template_path );
my $xslate = Text::Xslate->new(
path => [$template_path],
);
my $cv = AE::cv;
my $server = AnyEvent::JSONRPC::Lite::Server->new( port => $port );
$server->reg_cb( render => sub{
my ($res_cv, $template, $vars) = @_;
$res_cv->result($xslate->render($template,$vars));
},
);
$cv->recv;
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment