Skip to content

Instantly share code, notes, and snippets.

@masak
Created September 5, 2010 04:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save masak/565752 to your computer and use it in GitHub Desktop.
class Page {
has Str $.style = 'fill: #333333';
class Book {
has Str $.abbreviation;
has Str $.name;
has Str $.author;
has Str $.year;
has Page @.pages;
}
diagram BookLayouts {
element LAYOUT { <booktable> on <attribution> }
element booktable { table(<book> from .books, :4columns) }
element book { .abbreviation on table(<page> from .pages, :10columns) }
element page { <rect width="1" height="2" style="{.style}"> }
element attribution {
vline on "SOURCE BOOKS"
on table(<source> from .books, :2columns, :down)
}
element source { .name on "by $_.author, $_.year" }
}
my Book @books = ...;
BookLayouts.render(:@books);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment