sub source_file()

in src/lib/view.pm [47:79]


sub source_file
{
    # Note: those contributions didn't make their way from svn to git
    # TODO - do something...
    my $url = "http://svn.apache.org/repos/asf/velocity/" . shift;
    my $content = get $url;

    $content = "" if not $content;

    # extension gives lexer used for code highlighting
    if ($url =~ /\.([a-z]+)$/i)
    {
        my $accepted = "java properties xml vm vtl vhtml";
        my $ext = lc $1;
        if (index($accepted, $ext) != -1)
        {
            $ext =~ s/vm|vtl|vhtml/velocity/;
            $content = ":::$ext\n$content";
        }
    }

    # indent as block of code
    $content =~ s/^/    /smg;

    # filename gives block title
    if ($url =~ /(\w+\.[a-z]+)$/)
    {
        my $filename = $1;
        $content = "\n\n#### [$filename]($url)\n\n$content";
    }

    return $content;
}