mirror of
https://gitea.invidious.io/iv-org/shard-kilt.git
synced 2024-08-15 00:43:15 +00:00
Add specs for passing custom context to Liquid
E.g.: context = Liquid::Context.new context.set "key", "value" render( "/path/to/template.liquid", context)
This commit is contained in:
parent
61138dc4e8
commit
b7ee6a13d6
1 changed files with 20 additions and 0 deletions
|
@ -6,6 +6,26 @@ class LiquidView
|
|||
Kilt.file "spec/fixtures/test.liquid"
|
||||
end
|
||||
|
||||
class LiquidViewWithCustomContext
|
||||
# Use of instance variable is not required in user code. It is used here to
|
||||
# avoid name clash with 'context' variable existing within spec.
|
||||
def initialize
|
||||
@context = Liquid::Context.new
|
||||
@context.set "process", { "pid" => Process.pid }
|
||||
end
|
||||
Kilt.file "spec/fixtures/test.liquid", "__kilt_io__", "@context"
|
||||
end
|
||||
|
||||
it "renders liquid" do
|
||||
ctx = Liquid::Context.new
|
||||
ctx.set "process", { "pid" => Process.pid }
|
||||
Kilt.render("spec/fixtures/test.liquid", ctx).should eq("<span>#{Process.pid}</span>\n")
|
||||
end
|
||||
|
||||
it "works with classes" do
|
||||
LiquidView.new.to_s.should eq("<span>#{Process.pid}</span>\n")
|
||||
end
|
||||
|
||||
it "works with classes and custom context" do
|
||||
LiquidViewWithCustomContext.new.to_s.should eq("<span>#{Process.pid}</span>\n")
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue