Created
July 3, 2010 03:57
-
-
Save paul/462295 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'tilt' | |
require 'yajl' | |
module Tilt | |
class JrbBuilder < Template | |
def prepare | |
@code = data | |
end | |
def precompiled_template(locals) | |
@code | |
end | |
def collection(objects) | |
output = { | |
href: "http://example.com/databases", | |
item_count: objects.size, | |
items: objects.map { |o| render(o) } | |
} | |
::Yajl::Encoder.encode( | |
output, | |
:pretty => true | |
) | |
end | |
end | |
register 'jrb', JrbBuilder | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment