Created
September 4, 2012 10:32
-
-
Save MagnusEnger/3619844 to your computer and use it in GitHub Desktop.
POC for using Template Toolkit to display MARC data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use MARC::Batch; | |
use Template; | |
use Modern::Perl; | |
my $batch = MARC::Batch->new('USMARC', 'test.mrc'); | |
my $record = $batch->next(); | |
# Set up Template Toolkit | |
my $ttconfig = { | |
INCLUDE_PATH => '.', | |
}; | |
my $tt2 = Template->new( $ttconfig ) || die Template->error(), "\n"; | |
my $data = { | |
'record' => $record | |
}; | |
$tt2->process( 'marctt.tt', $data ) || die $tt2->error(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Title: | |
[% record.field('245').subfield('a') %] : [% record.field('245').subfield('b') %] | |
Publisher: | |
[% record.field('260').subfield('b') %] | |
Authors: | |
[%- FOREACH f IN record.field('700') %] | |
[% f.subfield('a') %] | |
[%- END %] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00693nam a22001932a 4500001001000000008004100010020002200051100001600073245011500089250001200204260005300216300001800269650003700287700001600324700002200340942000700362999001300369952011700382120459418 eng a9780596004927bh. aWall, Larry aProgramming PerlcLarry Wall, Tom Christiansen & Jon Orwantbunmatched power for text processing and scripting a4th ed. aBeijing ; Cambridge, Mass.bO'Reilly Mediac2012 a1184 s.bill. aPerl (Computer program language) aOrwant, Jon aChristiansen, Tom cBK c122d122 w2012-03-26p109r2012-07-1340009123bBIBm310d2012-03-26q2013-08-1270cSTAFF2ddcyBKs2012-07-13l2aBIB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment