Add jbuilder (#20)

This commit is contained in:
Rocky 2019-10-16 00:23:55 +08:00 committed by Jerome Gravel-Niquet
parent 43a5c472a6
commit 7603087d3d
4 changed files with 25 additions and 0 deletions

View file

@ -15,3 +15,5 @@ development_dependencies:
github: f/temel github: f/temel
liquid: liquid:
github: TechMagister/liquid.cr github: TechMagister/liquid.cr
jbuilder:
github: shootingfly/jbuilder

1
spec/fixtures/test.jbuilder vendored Normal file
View file

@ -0,0 +1 @@
json.span Process.pid

View file

@ -0,0 +1,18 @@
require "../spec_helper"
require "../../src/jbuilder"
class JbuilderView
Kilt.file "spec/fixtures/test.jbuilder"
end
describe "kilt/jbuilder" do
it "renders jbuilder" do
Kilt.render("spec/fixtures/test.jbuilder").should eq("{\"span\":#{Process.pid}}")
end
it "works with class" do
JbuilderView.new.to_s.should eq("{\"span\":#{Process.pid}}")
end
end

4
src/jbuilder.cr Normal file
View file

@ -0,0 +1,4 @@
require "./kilt"
require "jbuilder"
Kilt.register_engine "jbuilder", Jbuilder.embed