mirror of
https://gitea.invidious.io/iv-org/shard-kilt.git
synced 2024-08-15 00:43:15 +00:00
Compare commits
12 commits
Author | SHA1 | Date | |
---|---|---|---|
|
b7289f80ad | ||
|
7ffc3e82f2 | ||
|
ebeb955e53 | ||
|
bd8e6fd144 | ||
|
8282f54139 | ||
|
fe1a382088 | ||
|
d2c3c6b5ba | ||
|
7603087d3d | ||
|
43a5c472a6 | ||
|
0339265b3d | ||
|
ddba8f9050 | ||
|
bfd630f35c |
13 changed files with 97 additions and 3 deletions
|
@ -1 +1,3 @@
|
|||
language: crystal
|
||||
crystal:
|
||||
- latest
|
|
@ -1,4 +1,4 @@
|
|||
# Kilt [](https://travis-ci.org/jeromegn/kilt) [](https://shards.rocks/github/jeromegn/kilt) [](https://shards.rocks/github/jeromegn/kilt)
|
||||
# Kilt [](https://travis-ci.org/jeromegn/kilt)
|
||||
|
||||
Generic templating interface for Crystal.
|
||||
|
||||
|
@ -15,6 +15,9 @@ Simplify developers' lives by abstracting template rendering for multiple templa
|
|||
| Slang | .slang | [slang](https://github.com/jeromegn/slang) | [@jeromegn](https://github.com/jeromegn) |
|
||||
| Temel | .temel | [temel](https://github.com/f/temel) | [@f](https://github.com/f) |
|
||||
| Crikey | .crikey | [crikey](https://github.com/domgetter/crikey) | [@domgetter](https://github.com/domgetter) |
|
||||
| Liquid | .liquid | [liquid](https://github.com/TechMagister/liquid.cr) | [@docelic](https://github.com/docelic) |
|
||||
| Jbuilder | .jbuilder | [jbuilder](https://github.com/shootingfly/jbuilder) | [@shootingfly](https://github.com/shootingfly) |
|
||||
| Water | .water | [water](https://github.com/shootingfly/water) | [@shootingfly](https://github.com/shootingfly) |
|
||||
|
||||
See also:
|
||||
[Registering your own template engine](#registering-your-own-template-engine).
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
name: kilt
|
||||
version: 0.4.0
|
||||
version: 0.6.1
|
||||
crystal: '< 2.0.0'
|
||||
|
||||
authors:
|
||||
- Jerome Gravel-Niquet <jeromegn@gmail.com>
|
||||
|
@ -13,3 +14,9 @@ development_dependencies:
|
|||
github: MakeNowJust/crustache
|
||||
temel:
|
||||
github: f/temel
|
||||
liquid:
|
||||
github: TechMagister/liquid.cr
|
||||
jbuilder:
|
||||
github: shootingfly/jbuilder
|
||||
water:
|
||||
github: shootingfly/water
|
||||
|
|
1
spec/fixtures/test.jbuilder
vendored
Normal file
1
spec/fixtures/test.jbuilder
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
json.span Process.pid
|
1
spec/fixtures/test.liquid
vendored
Normal file
1
spec/fixtures/test.liquid
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<span>{{ process.pid }}</span>
|
1
spec/fixtures/test.water
vendored
Normal file
1
spec/fixtures/test.water
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
span Process.pid
|
18
spec/kilt/jbuilder_spec.cr
Normal file
18
spec/kilt/jbuilder_spec.cr
Normal 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
|
31
spec/kilt/liquid_spec.cr
Normal file
31
spec/kilt/liquid_spec.cr
Normal file
|
@ -0,0 +1,31 @@
|
|||
require "../spec_helper"
|
||||
require "../../src/liquid"
|
||||
|
||||
class LiquidView
|
||||
@process = { "pid" => Process.pid }
|
||||
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
|
18
spec/kilt/water_spec.cr
Normal file
18
spec/kilt/water_spec.cr
Normal file
|
@ -0,0 +1,18 @@
|
|||
require "../spec_helper"
|
||||
require "../../src/water"
|
||||
|
||||
class WaterView
|
||||
Kilt.file "spec/fixtures/test.water"
|
||||
end
|
||||
|
||||
describe "kilt/water" do
|
||||
|
||||
it "renders water" do
|
||||
Kilt.render("spec/fixtures/test.water").should eq("<span>#{Process.pid}</span>")
|
||||
end
|
||||
|
||||
it "works with class" do
|
||||
WaterView.new.to_s.should eq("<span>#{Process.pid}</span>")
|
||||
end
|
||||
|
||||
end
|
4
src/jbuilder.cr
Normal file
4
src/jbuilder.cr
Normal file
|
@ -0,0 +1,4 @@
|
|||
require "./kilt"
|
||||
require "jbuilder"
|
||||
|
||||
Kilt.register_engine "jbuilder", Jbuilder.embed
|
|
@ -1,3 +1,3 @@
|
|||
module Kilt
|
||||
VERSION = "0.4.0"
|
||||
VERSION = "0.6.1"
|
||||
end
|
||||
|
|
4
src/liquid.cr
Normal file
4
src/liquid.cr
Normal file
|
@ -0,0 +1,4 @@
|
|||
require "./kilt"
|
||||
require "liquid"
|
||||
|
||||
Kilt.register_engine "liquid", Liquid.embed
|
4
src/water.cr
Normal file
4
src/water.cr
Normal file
|
@ -0,0 +1,4 @@
|
|||
require "./kilt"
|
||||
require "water"
|
||||
|
||||
Kilt.register_engine "water", Water.embed
|
Loading…
Add table
Add a link
Reference in a new issue